我正在为asp.net开发一个项目,并添加了我删除记录的代码。但是,当我运行它时,我收到错误
数据源“SqlDataSource1”不支持删除,除非 指定了DeleteCommand。
广泛的谷歌搜索没有得到足够的答案。此外,当我检查我的SQL表时,删除命令已成功删除该条目,但仍然出现此错误。任何帮助将不胜感激。
Protected Sub GridView1_RowDeleting(sender As Object, e As GridViewDeleteEventArgs) Handles GridView1.RowDeleting
Dim thisID As String
Dim strSQL As String
' Get the id - Cell(0) is the first column in the grid
' If you have the delete or edit links on the left this column will change!
thisID = GridView1.Rows(e.RowIndex).Cells(5).Text
' Delete the specific record
' Use hard-coded values first to check your work
' strSQL = "DELETE FROM userTable WHERE id = 25"
strSQL = "DELETE FROM " & TABLE_NAME & " WHERE Name = '" & thisID & "'"
runNonSelect(strSQL)
RefreshGrid()
End Sub