ImportRow() doesn't save changes to database table

G

Guest

Can anybody help me please.
I'm new to VB.NET and I'm trying to import some data from SQL Server to MS
Access but cannot make it to work (note: I don't want to use DTS)
.....goes like this...

Dim daSql As New SqlDataAdapter("select * from table1", SqlConnection)
Dim dsSql As New DataSet() ' to hold info from SQL Server
daSql.Fill(dsSql, "table1")

Dim daAcc As New OleDb.OleDbDataAdapter("select * from table2",
AccessConnection)
' table2 is an empty table with the same schema as table1
Dim dsAcc As New DataSet() 'to hold info for Access
daAcc.Fill(dsAcc, "table2")

For i as Integer = 0 To dsSql.Tables(0).Rows.Count - 1
dsAcc.Tables(0).NewRow()
dsAcc.Tables(0).ImportRow(dsSql.Tables(0).Rows(i))
Next i

dsAcc.Tables(0).AcceptChanges(0
daAcc.AcceptChangesDuringUpdate = True
daAcc.Update(dsAcc, "table2")

'...end

what am I doing wrong?
messagebox inserted anywhere after For..Next loop shows desired number of
rows in Access dataSet but the are no changes made to the actual database.
 
G

Guest

mikus,

AcceptChanges is re-setting the rows to indicate no changes have been made.

Try it without the AcceptChanges.

Kerry Moorman
 
G

Guest

Thank you for such a prompt response however after removing AcceptChanges
from the code the result is still the same.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top