I am deleting selected row from grid view.
使用以下代码行从 gridview 中删除,但未从数据库中删除。它显示了将 varchar 转换为 int 的错误
Private Sub dltButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles dltButton.Click
'Dim StudentId As String
'StudentId =
'con.Open()
'cmd.CommandText = "delete from KaiyumVbStudent where StudentID = '"&StudentId&"'"
'cmd.Connection = con
Dim i As Integer = DataGridView1.CurrentRow.Index
DataGridView1.Rows.Remove(DataGridView1.CurrentRow)
StudentID = CType(DataGridView1.SelectedCells(2), TextBox).Text
con = New SqlConnection(constring)
con.Open()
cmd = New SqlCommand("Delete from KaiyumVbStudent where StudentID = '@StudentID'", con)
cmd.ExecuteNonQuery()
Call databind()
End Sub