【发布时间】:2011-01-26 09:20:16
【问题描述】:
我有一张桌子 AVUKAT
Columns--> HESAP, MUSTERI, AVUKAT
这是我的删除按钮代码
protected void Delete_Click(object sender, EventArgs e)
{
string strConnectionString = ConfigurationManager.ConnectionStrings["SqlServerCstr"].ConnectionString;
SqlConnection myConnection = new SqlConnection(strConnectionString);
myConnection.Open();
string hesap = Label1.Text;
string musteriadi = DropDownList1.SelectedItem.Value;
string avukat = DropDownList2.SelectedItem.Value;
SqlCommand cmd = new SqlCommand("DELETE FROM AVUKAT WHERE (@HESAP, @MUSTERI, @AVUKAT)", myConnection);
cmd.Parameters.AddWithValue("@HESAP", hesap);
cmd.Parameters.AddWithValue("@MUSTERI", musteriadi);
cmd.Parameters.AddWithValue("@AVUKAT", avukat);
cmd.Connection = myConnection;
SqlDataReader dr = cmd.ExecuteReader(CommandBehavior.CloseConnection);
Grid_Goster.DataSource = dr;
Grid_Goster.Visible = true;
myConnection.Close();
}
但它会产生这样的错误。
Server Error in '/' Application.
An expression of non-boolean type specified in a context where a condition is expected, near ','.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Data.SqlClient.SqlException: An expression of non-boolean type specified in a context where a condition is expected, near ','.
Source Error:
Line 83: cmd.Connection = myConnection;
Line 84:
Line 85: SqlDataReader dr = cmd.ExecuteReader(CommandBehavior.CloseConnection);
Line 86: Grid_Goster.DataSource = dr;
Line 87: Grid_Goster.Visible = true;
我找不到错误.. 在哪里?
【问题讨论】:
标签: c# asp.net database sqldatareader sql-delete