我有一个数据绑定的datagridview,我想添加更新和删除按钮,这将打开另一个包含需要更新的记录的表单。 datagrid就是这样的
conn = New MySqlConnection
conn.ConnectionString = "server=localhost;userid=root;password=root;database=test"
Dim sda As New MySqlDataAdapter
Dim dbDataset As New DataSet
Dim bsource As New BindingSource
Try
conn.Open()
Dim query As String
query = "select user_id as 'ID', lname as 'Lastname', fname as 'Firstname' from test.user"
comm = New MySqlCommand(query, conn)
sda.SelectCommand = comm
sda.Fill(dbDataset)
bsource.DataSource = dbDataset
userDatagridview.DataSource = bsource
sda.Update(dbDataset)
conn.Close()
Catch ex As MySqlException
MessageBox.Show(ex.Message)
Finally
conn.Dispose()
End Try