VS中增加模糊查询之后 sda.Fill(ds); 报异常
privatevoidbutton1_Click(objectsender,EventArgse){stringconStr="server=.;database=ton...
private void button1_Click(object sender, EventArgs e)
{
string conStr="server=.;database=tongxunlu;integrated security=true";
SqlConnection con = new SqlConnection(conStr);
string sql = @"select * from tongxunlu_1 where (姓名 like '%" + textBox1.Text + "%'" + @" and
类别 '%" + textBox2.Text + @"%')
ORDER BY A.TEST_TIME DESC";
SqlCommand cmd = new SqlCommand(sql, con);
//DataTable dt = new DataTable();
DataSet ds=new DataSet();
SqlDataAdapter sda = new SqlDataAdapter(cmd);
sda.Fill(ds); ←这一行 报错 ↓ 下边是 错误信息
An unhandled exception of type 'System.Data.SqlClient.SqlException'
occurred in System.Data.dll
dataGridView1.DataSource = ds.Tables[0]; 展开
{
string conStr="server=.;database=tongxunlu;integrated security=true";
SqlConnection con = new SqlConnection(conStr);
string sql = @"select * from tongxunlu_1 where (姓名 like '%" + textBox1.Text + "%'" + @" and
类别 '%" + textBox2.Text + @"%')
ORDER BY A.TEST_TIME DESC";
SqlCommand cmd = new SqlCommand(sql, con);
//DataTable dt = new DataTable();
DataSet ds=new DataSet();
SqlDataAdapter sda = new SqlDataAdapter(cmd);
sda.Fill(ds); ←这一行 报错 ↓ 下边是 错误信息
An unhandled exception of type 'System.Data.SqlClient.SqlException'
occurred in System.Data.dll
dataGridView1.DataSource = ds.Tables[0]; 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询