Good morning all,
I try to affect a filter / search on datagridview by a combobox and textbox but when I type the first letter (s) on textbox an error message is displayed:
System.Data.SqlClient.SqlException*: 'Syntaxe incorrect vers 's%'.'
here is my code:
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- using System.Configuration;
- using System.Data.SqlClient;
-
- namespace TESTSEARCH
- {
- public partial class FormFind : Form
- {
- public FormFind()
- {
- InitializeComponent();
- }
- private void FormFind_Load(object sender, EventArgs e)
- {
- }
- private void textBox1_TextChanged(object sender, EventArgs e)
- {
- string constring = ConfigurationManager.ConnectionStrings["TESTDEMO.Properties.Settings.connect"].ConnectionString;
- SqlConnection con = new SqlConnection(constring);
- if (comboBox1.Text == "BD_NameConn")
- {
- SqlDataAdapter Sda = new SqlDataAdapter ("Select BD_NameConn, BD_BaseType, BD_Base, BD_Serer, BD_User, BD_MenuStyle FROM BD WHERE BD_NameConn '" + textBox1.Text + "%'",con);
- DataTable Dt = new DataTable();
- Sda.Fill(Dt);
- dataGridView1.DataSource = Dt;
- }
- }
- }
- }
it stops in the line Sda.Fill (Dt); and displays the message :
System.Data.SqlClient.SqlException*: 'Syntaxe incorrecte vers 's%'.'
I await your help and thank you in advance