protected void dellall(object sender, EventArgs e)
{
int i;
string strSql = "";
CheckBox mycheck = new CheckBox();
for (i = 0; i < DataGrid1.Items.Count; i++)
{
mycheck = (CheckBox)DataGrid1.Items[i].FindControl("mycheck");
if (mycheck.Checked == true)
{
strSql = strSql + ((CheckBox)this.DataGrid1.Items[i].FindControl("mycheck")).Text.Trim() + ",";
}
}
if (strSql == "")
{
MessageBox.Show(this, "没有选定内容!");
return;
}
string strSql1 = "delete * from News where NewsId in(" + strSql + ")";
DB.execnonsql(strSql1);
Page.ClientScript.RegisterStartupScript(this.GetType(), "Startup", "<script>alert('您已经成功删除数据!');window.location.href='M_News.aspx'</script>");//无刷新弹出对话框
binddr();
}delete * from News where NewsId in(" + strSql + ")"; 这句在ACCESS 中能执行 但sqlite 中不行呵!
{
int i;
string strSql = "";
CheckBox mycheck = new CheckBox();
for (i = 0; i < DataGrid1.Items.Count; i++)
{
mycheck = (CheckBox)DataGrid1.Items[i].FindControl("mycheck");
if (mycheck.Checked == true)
{
strSql = strSql + ((CheckBox)this.DataGrid1.Items[i].FindControl("mycheck")).Text.Trim() + ",";
}
}
if (strSql == "")
{
MessageBox.Show(this, "没有选定内容!");
return;
}
string strSql1 = "delete * from News where NewsId in(" + strSql + ")";
DB.execnonsql(strSql1);
Page.ClientScript.RegisterStartupScript(this.GetType(), "Startup", "<script>alert('您已经成功删除数据!');window.location.href='M_News.aspx'</script>");//无刷新弹出对话框
binddr();
}delete * from News where NewsId in(" + strSql + ")"; 这句在ACCESS 中能执行 但sqlite 中不行呵!
解决方案 »
- 定时读取XML更新到数据库问题 ~~~~
- 请问我在用MSChart时出现错误:"为 ChartImg.axd 执行子请求时出错"
- Excel COM+保存时的异常
- SqlDataSource控件的SelectCommand设置LIKE语句的时候报错
- asp.net 编译后生成的DLL文件的大小与网页打开速度有关系吗?
- 如何向xml文件添加元素?
- ##--如何把Javascript中的一个值传到ASP.net中处理--##
- 我想搞个后台修改Global.asax.cs页面设置的常数的信息,请问该如何实现?
- 关于ajax tab控件和gridview问题
- 如何用RequiredFieldValidator控件验证DataGrid中的TextBox
- 有熟悉Spring.net、NHibernate两个东东的朋友进来一下啊
- .net ajax客户端调用 webservic 返回DataTable "序列化类型为“System.Reflection.Module”的对象时检测到循环引用
另外,strSql後面有個","你要去掉
建议dubug一下查一下 strSql 的值
重点 最后的逗号是否删除,若NewsId是字符类型,各项目有没加单引号
ps' 这样写比较危险.... 建议用参数写法
string strSql1 = "delete from News where NewsId in(" + strSql + ")";
第一 去掉"," "*" 符号能删掉单一记录!
但多记录,只能删除一条! 不能全删除!去掉";"留下“*”提示以下
SQLite error
near "*": syntax error 去掉“*” 留下","SQLite error
near ")": syntax error
看下CheckBox中的内容
看下sql语句有什么问题没有
把sql语句放到查询分析器上看看可不可用、有什么错误没
SELECT TOP 10 * FROM [index] ORDER BY indexid DESC; 但是这条SQL语句在SQLite中是无法执行的,应该改为:SELECT * FROM [index] ORDER BY indexid DESC limit 0,10