Create DataTable to insert to a MySQL database (MySQL.data)
Posted on 2007-07-20
I have some questions regarding datatables in VB.net vs 2005.
I have a database table (MySQL 5) I want to update using the dataadapter in MySQL.data
To do that I need to fill a datatable with all the information I want to insert if I understand this correct? :)
To get the best result I have heard here is that I need to create the datable with the same column name and the same type as in my database table.
So how do I create my datatable?
I have read the MSDN and I found this function, is this the way I shold use to make my table? or is there a better way to create the table I need?
Private Sub AddDataColumn(ByVal table As DataTable)
Dim typeInt32 As System.Type = _
Dim column As DataColumn = _
New DataColumn("id", typeInt32)
' Set various properties.
.AutoIncrement = True
.AutoIncrementSeed = 1
.AutoIncrementStep = 1
.ReadOnly = True
' Add to Columns collection.