Updating a database Problem .. PLEASE HELP!!
Posted on 2005-04-11
I need to update a database from a datatable that i generate from a text file that i parsed. The datatable is full of data, but i don't know how to get the update method of the dataadapter to work for this table, since no dataadapter was used to create the table. please note i am trying to approach this from an untyped dataset. Im still pretty novice to .VB compared to the rest of you so be patient with me a little at trying to expalain.
here is my code it may be way off:
Public Sub AddProducts(ByVal dt As DataTable)
Dim sql As String = "select name, sku from product"
Dim cmd As New OleDbCommand(sql, NewConnection()) 'This gets connection from other method ... this works
Dim dap1 As New OleDbDataAdapter(cmd)
Dim cb As New OleDbCommandBuilder(dap1)
.UpdateCommand = cb.GetUpdateCommand
.DeleteCommand = cb.GetDeleteCommand
.InsertCommand = cb.GetInsertCommand
Here is the code that i used to make the table
Private Sub BuildDataTable()
dasProduct = New DataSet
dtProduct = New DataTable("Product")
Dim i As Integer
Dim clsproduct As Product
For i = 1 To m_cProducts.Count
clsproduct = m_cProducts.Item(i)
Dim oaFields(2) As Object
oaFields(0) = .Name
oaFields(1) = .SKU