strSql = "Delete from news where id=" & intId 

解决方案 »

  1.   

    strSql = "Delete from news where [id]=@[id]"
      

  2.   

    .......        
            strSql = "Delete from news where id=" & intId
            cmd = New OleDbCommand(strSql, con)
            con.Open()
            Try
                intCount = cmd.ExecuteNonQuery
            Catch ex As Exception
                lblErrMessage.Text = ex.Message
            Finally
                con.Close()
            End Try
    .......
     你的程序中@id从哪里来的??呵呵!上面的应该可以吧,你试一下
      

  3.   

    strSql = "DELETE FROM 表名 WHERE id=@id";另外,看看你的表名有没有问题!
      

  4.   

    nk912114 我同样觉的你的办法可以 但还是不行 intId  来自于
     Private Sub dlstNews_DeleteCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataListCommandEventArgs) Handles dlstNews.DeleteCommand
            Dim intId As Integer
            intId = CInt(dlstNews.DataKeys(e.Item.ItemIndex))
            bindNews_delete(intId)
        End Sub
    对了 我用的是access 数据库
      

  5.   

    哦!access数据库不支持delete from ...
    请写成
    strSql = "Delete from news where id="+intId
      

  6.   

    不支持吗
    上下没区别啊 就是delete from  和Delete from 有区别吗?
      

  7.   

    你用的是ACCESS数据库 ID是关键字,不能用
    你换一个名字就可以了比如说RevordID?=
    试试吧
      

  8.   

    如果不用参数化查询的话(@ID),发送到数据库的条件字符串加单引号(id = 'idex');