Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
Delete Button
Dim mydataset As New DataSet
Dim mydataAdapter As New MySqlDataAdapter
Try
Dim int As Integer = DataGridView1.SelectedRows(0).Index
DataGridView1.Rows.Remove(DataGridView1.SelectedRows(0))
mydataset.Tables(0).Rows(int).Delete()
mydataAdapter.Update(mydataset, "datainfo")
MessageBox.Show("Success!")
Catch ex As Exception
End Try
End Sub
答案 0 :(得分:0)
1)不要使用mydataAdapter.Update(mydataset," datainfo")
2)尝试使用SqlCommandBuilder,如下所示:
Dim ESCBuilder As SqlCommandBuilder = New SqlCommandBuilder(mydataAdapter)
ESCBuilder.GetUpdateCommand()
da.UpdateCommand = ESCBuilder.GetUpdateCommand()
da.Update(mydataset)
3)尝试阅读有关System.Data.SqlClient命名空间的几乎所有内容。希望它有所帮助