关于ASp.NET的GridView控件连接SQL2005数据库问题

来源:百度知道 编辑:UC知道 时间:2024/06/04 09:34:41
请教高手为什么我的代码说我的 “where”语句附近错误啊 在线等!好的加分谢谢!!

string whereCondition = "";
if (DropDownList1.SelectedValue != "" && TextBox1.Text == "")
whereCondition = "WHERE emptdept='" + DropDownList1.SelectedValue + "' ORDER BY deptid DESC";
if (DropDownList1.SelectedValue == "" && TextBox1.Text != "")
whereCondition = "WHERE emptname='" + TextBox1.Text + "' ORDER BY deptid DESC";
if (DropDownList1.SelectedValue != "" && TextBox1.Text != "")
whereCondition = "WHERE emptdept='" + DropDownList1.SelectedValue + "' AND emptname='" + TextBox1.Text + "' ORDER BY deptid DESC";
if (TextBox1.Text == "" && TextBox1.Text == "")
whereCondition = "ORDER BY deptid DESC";

自己断点调试吧,这样复制上来后代码可能已经不同了。
SQL语句里在中文状态下输入的 空格都能造成SQL的语法错误。
好眼花的SQL语句。

emptid;" 多了一个分号?

你用断点测试下..看看给你的具体提示是什么.