我有两张桌子,我想使用TextBox
搜索它们,这是我的代码,但错误的希望能帮助我
string constring = "Data Source =.; initial Catalog = business; Integrated Security=SSPI;";
SqlConnection CN = new SqlConnection(constring);
DataTable dt = new DataTable();
if (txtID.Text.Trim() != "")
{
SqlDataAdapter sda = new SqlDataAdapter("select tab1.ID ,tab1.DATMOSTAND ,tab1.MONY ,tab2.BYAN ,tab2.MONY from MAL_ERTEBAT,tab2 where tab1.ID = tab2.EID = '" + txtID.Text + "'", CN);
sda.Fill(dt);
}
dataGridView1.DataSource = dt;
其中tab1.ID = tab2.EID ='“+ txtID.Text +”'“这是消息的错误部分”正确语法near =“
答案 0 :(得分:0)
希望您错过alias
名称:
将以上SqlDataAdapter
替换为:
SqlDataAdapter sda = new SqlDataAdapter("select tab1.ID ,tab1.DATMOSTAND ,tab1.MONY ,tab2.BYAN ,tab2.MONY from MAL_ERTEBAT tab1,tab2 where tab1.ID = tab2.EID = '" + txtID.Text + "'", CN);