每当我运行它时,这个异常就会出现“当nvarchar值'columnvalue‘转换为datatype时,转换失败。”知道为什么吗?这也是删除一行的永久方式吗?谢谢你对未来的建议!
Dim dataindex As Integer = Me.DataGridView1.CurrentRow.Index
Try
con = New SqlConnection
con.ConnectionString = Login.constring
Dim cmd As New SqlCommand("DELETE FROM tblmovies where movietitle = @a ", con)
cmd.Parameters.Add(New SqlParameter("@a", dataindex))
con.Open()
If MessageBox.Show("Do you really want to Delete this Record?", "Delete", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) = DialogResult.Yes Then
cmd.ExecuteNonQuery()
con.Close()
Exit Sub
Else
con.Close()
Exit Sub
End If
Catch ex As SqlException
MessageBox.Show(ex.Message)
End Try 发布于 2017-02-25 13:43:05
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim i As Integer = DataGridView1.SelectedRows(0).Index
DataGridView1.Rows.RemoveAt(i)
End Subhttps://stackoverflow.com/questions/42456594
复制相似问题