我有两个表,我想使用 a 搜索它们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 + "'" 这是错误部分,消息是“在 = 附近的正确语法