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;
- }
- }
- }
- }
System.Data.SqlClient.SqlException*: 'Syntaxe incorrecte vers 's%'.'
I await your help and thank you in advance

Jignesh KumarRank #91 · 22.9K reputationPosted Apr 18, 2020, 9:16 AM EDT
Rajanikant HawaldarRank #110 · 20.2K reputationPosted Apr 17, 2020, 2:10 AM EDT
Vinay SinghRank #604 · 4K reputationPosted Apr 17, 2020, 5:06 AM EDT