I Use visual Basic 8.0 and Mysql 5.0
I have one Table1:
RecordID , Integer = primary key auto_increment NOT NULL
Articlenr , Integer
Table1: has two records:
RecordID, Articlenr ,Articlename
1 , 1000, Hamer
2 , 2000, saw
I want to use Datagridview to update Mysql table1.
All changes as update, change, delete automatically processed into Mysql table1.
Here by my code
really want to now can I link Mydataset to DataGridView1 and Mysql table1?
I now i must do something with MySqlCommandBuilder!
Dim MyCommand1 As New MySql.Data.MySqlClient.MySqlCommand Dim Myadapter As New MySql.Data.MySqlClient.MySqlDataAdapter Dim MyBuilder As New MySql.Data.MySqlClient.MySqlCommandBuilder Dim MyDataTable As New DataTable DIM MyDataset As Dataset MyCommand1.CommandText = "select * from Table1" MyCommand1.Connection = conn Myadapter.SelectCommand = MyCommand Myadapter.Fill(MyDatatable) Myadapter.Fill(MydataSet) DataGridView1.DataSource = MyDatatable If MydataSet.GetChanges() Is Nothing Then MessageBox.Show("The table contains no changes to save.") Else Dim rowsAffected As Integer = Myadapter.Update(MyDatatable) If rowsAffected = 0 Then MessageBox.Show("No rows were affected by the save operation.") Else MessageBox.Show(rowsAffected & " rows were affected by the save operation.") End If End If