我试图在消息框中显示 SQL 查询的结果,但我无法让它工作。
这是我的代码:
SqlConnection CN = new SqlConnection(constring);
DataTable dt = new DataTable();
CN.Open();
SqlDataAdapter sda = new SqlDataAdapter("select (Table_MAL_MEZANYAMASROF.MOKHASASMEZANYA- sum (MAL_ERTEBAT.MONY)) as 'debit' from Table_MAL_MEZANYAMASROF,MAL_ERTEBAT where Table_MAL_MEZANYAMASROF.BANDNO=MAL_ERTEBAT.BANDNO and MAL_ERTEBAT.BANDNO= '" + EdkhalBayanto.txtBandNo.Text + "'and MAL_ERTEBAT.BANDNAME = '" + EdkhalBayanto.txtBandName.Text + "' group by Table_MAL_MEZANYAMASROF.MOKHASASMEZANYA", CN);
sda.Fill(dt);
MessageBox.Show(dt);