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 中不行呵!

解决方案 »

  1.   

    delete from 而不是delete * from.
    另外,strSql後面有個","你要去掉
      

  2.   


    建议dubug一下查一下 strSql 的值
    重点 最后的逗号是否删除,若NewsId是字符类型,各项目有没加单引号
    ps' 这样写比较危险.... 建议用参数写法
      

  3.   

    看看strSql1 里面的值在Access查询里面是否可以正常执行
      

  4.   

    strSql = strSql.Substring(0, strSql.Length - 1);
    string strSql1 = "delete from News where NewsId in(" + strSql + ")"; 
      

  5.   


    第一 去掉"," "*" 符号能删掉单一记录!
    但多记录,只能删除一条! 不能全删除!去掉";"留下“*”提示以下
    SQLite error
    near "*": syntax error 去掉“*” 留下","SQLite error
    near ")": syntax error 
      

  6.   

    用断点调试下
    看下CheckBox中的内容
    看下sql语句有什么问题没有
     把sql语句放到查询分析器上看看可不可用、有什么错误没
      

  7.   

    http://www.sqlite.com.cn/MySqlite/3/250.Html
    SELECT TOP 10 * FROM [index] ORDER BY indexid DESC; 但是这条SQL语句在SQLite中是无法执行的,应该改为:SELECT * FROM [index] ORDER BY indexid DESC limit 0,10