TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Ghali Mongi
NA
5
1.1k
Problem with Search DataGridView by using ComboBox and Text
Apr 17 2020 6:01 AM
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
Reply
Answers (
3
)
Produce Manual beep sound from Magellan 9800i scanner scale
HOW TO POPULATE Datagridview using Async Awaits in C# WINFOR