HighTechTalks DotNet Forums  

Transfer Data from Sql Server to Access table

Dotnet Framework (ADO.net) microsoft.public.dotnet.framework.adonet


Discuss Transfer Data from Sql Server to Access table in the Dotnet Framework (ADO.net) forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
Cyrille Armand
 
Posts: n/a

Default Transfer Data from Sql Server to Access table - 12-01-2007 , 02:18 PM






Hi

Help a newbie!!!

I am trying to copy the content of a datatable (dt) into an Access table. It
seems the datatable has the data I want, and when I execute the code below it
doesn't generate errors, my only problem is that it doesn't work. Once I open
my Access db, the table is still empty. What gives?


Dim oleDa As OleDbDataAdapter = New OleDbDataAdapter("Select
* fom " + Table.Name, cnn.ConnectionString)
Dim Ocmd As OleDbCommandBuilder = New
OleDbCommandBuilder(oleDa)

oleDa.AcceptChangesDuringFill = False
oleDa.Fill(dt)
oleDa.Update(dt)
oleDa.Dispose()

Reply With Quote
  #2  
Old   
W.G. Ryan
 
Posts: n/a

Default Re: Transfer Data from Sql Server to Access table - 12-05-2007 , 01:40 PM






Cyrille:

You are using one adapter to Fill thetable and the same adapter to try to
update it. It looks like it's just going to populate the source table.
You'll need a different adapter for the destination table. Actually, now
that I look at it, i see why it's not throwing an error. You can pulling
from an empty table in all likelihood, so there are no rows. If you check
the Rows.count property of dt, right before you call Update, how many rows
are there?

The end problem though is that you'll need a different adapter or you'll
have to reconfigure your adatper if you want to move the data to a different
table. calling fill, then update on the same one will just yeild in the
same rows (assuming there are rows) b/c your source and destination tables
are the same unless there's other code I'm not seeing here. Typically, you
fill from one table (the acceptchangesduringfill is correct) but you use a
second adapter to call Update on, passing in the same datatable you filled
with the first Adapter.

Does that make sense?
"Cyrille Armand" <CyrilleArmand (AT) discussions (DOT) microsoft.com> wrote

Quote:
Hi

Help a newbie!!!

I am trying to copy the content of a datatable (dt) into an Access table.
It
seems the datatable has the data I want, and when I execute the code below
it
doesn't generate errors, my only problem is that it doesn't work. Once I
open
my Access db, the table is still empty. What gives?


Dim oleDa As OleDbDataAdapter = New
OleDbDataAdapter("Select
* fom " + Table.Name, cnn.ConnectionString)
Dim Ocmd As OleDbCommandBuilder = New
OleDbCommandBuilder(oleDa)

oleDa.AcceptChangesDuringFill = False
oleDa.Fill(dt)
oleDa.Update(dt)
oleDa.Dispose()



Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.