Google Groups Home
Help | Sign in
HowTo copy data between two databases using ado.net
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  6 messages - Collapse all
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
msnews.microsoft.com  
View profile
 More options Dec 12 2003, 6:57 am
Newsgroups: microsoft.public.dotnet.framework.adonet
From: "msnews.microsoft.com" <A...@B.COM>
Date: Fri, 12 Dec 2003 06:56:39 -0800
Local: Fri, Dec 12 2003 9:56 am
Subject: HowTo copy data between two databases using ado.net
I need to copy data between 2 sql servers using ado.net
this is currently done in vb6/ado record by record for the tables in a
config file

Since a dataset is disconnected, is there a way to pull all the data that's
required, set the row status flags to new record, and call database update
using this dataset

Thanks much
Suds
p/s
In case you're wondering, sql server replication does not work because of
firewall/security issues


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Miha Markic  
View profile
 More options Dec 12 2003, 7:39 am
Newsgroups: microsoft.public.dotnet.framework.adonet
From: "Miha Markic" <miha at rthand com>
Date: Fri, 12 Dec 2003 13:34:35 +0100
Local: Fri, Dec 12 2003 7:34 am
Subject: Re: HowTo copy data between two databases using ado.net
Hi,

"msnews.microsoft.com" <A...@B.COM> wrote in message

news:e2oXGcKwDHA.2352@TK2MSFTNGP09.phx.gbl...

> I need to copy data between 2 sql servers using ado.net
> this is currently done in vb6/ado record by record for the tables in a
> config file

> Since a dataset is disconnected, is there a way to pull all the data
that's
> required, set the row status flags to new record

Knowing which records are required is gona to be hard.
For new records:
One way would be to query target server for the last record id (in case you
have an autoincrement pk or something) and fetch only newer records from
source server.
For updates: you'll have to compare one ore more colums. (timestamp column
would be the best IMO)
Set AcceptChangesDuringFill to false - that will leave rows as "new" when
filled to datatable.
For updated rows you'll have to invoke AcceptChanges() on that row and
change a field to itself (that will cause the row to be marked as Modified).

, and call database update

> using this dataset

No problem on that if your data in dataset is configured ok.

--
Miha Markic - RightHand .NET consulting & software development
miha at rthand com


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
msnews.microsoft.com  
View profile
 More options Dec 12 2003, 10:28 pm
Newsgroups: microsoft.public.dotnet.framework.adonet
From: "msnews.microsoft.com" <A...@B.COM>
Date: Fri, 12 Dec 2003 22:25:06 -0800
Local: Sat, Dec 13 2003 1:25 am
Subject: Re: HowTo copy data between two databases using ado.net
sorry i did not explain everything in detail but you are right on the mark
all the tables have an identity column and the config has the last updated
autoincrement value
so copying is rather simple with reading all rows with identity column >
last value
and insert them into the new database which have identity insert enabled

If i understand your post correctly, i need to set AcceptChangesDuringFill =
false before ds.Fill()
and then call dataadaptor.update(ds) and the target database gets updated,
right ?

"Miha Markic" <miha at rthand com> wrote in message
news:OjtfJzKwDHA.2460@TK2MSFTNGP10.phx.gbl...


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Miha Markic  
View profile
 More options Dec 13 2003, 3:26 am
Newsgroups: microsoft.public.dotnet.framework.adonet
From: "Miha Markic" <miha at rthand com>
Date: Sat, 13 Dec 2003 09:22:23 +0100
Local: Sat, Dec 13 2003 3:22 am
Subject: Re: HowTo copy data between two databases using ado.net

"msnews.microsoft.com" <A...@B.COM> wrote in message

news:egpz7iSwDHA.2080@TK2MSFTNGP10.phx.gbl...

> sorry i did not explain everything in detail but you are right on the mark
> all the tables have an identity column and the config has the last updated
> autoincrement value
> so copying is rather simple with reading all rows with identity column >
> last value
> and insert them into the new database which have identity insert enabled

> If i understand your post correctly, i need to set AcceptChangesDuringFill
=
> false before ds.Fill()
> and then call dataadaptor.update(ds) and the target database gets updated,
> right ?

Right. If you want to insert new rows, yes.

--
Miha Markic - RightHand .NET consulting & development
miha at rthand com


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Rick Reynolds  
View profile
 More options Dec 23 2003, 4:02 pm
Newsgroups: microsoft.public.dotnet.framework.adonet
From: Rick Reynolds <rreyno...@warrantycorp.com>
Date: Tue, 23 Dec 2003 13:01:11 -0800
Local: Tues, Dec 23 2003 4:01 pm
Subject: Re: HowTo copy data between two databases using ado.net

Hello,

I read this thread and it's similar to something I'm trying to do. I
want to copy data between a text data source and an SQL table. I have
been able to get the data from the text file into a dataset but I don't
understand how to use that to insert records to a SQL server table. If
you could provide a little more detail on how this might be done it
would be greatly appreciated.

Thanks,
Rick

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Miha Markic  
View profile
 More options Dec 23 2003, 4:19 pm
Newsgroups: microsoft.public.dotnet.framework.adonet
From: "Miha Markic" <miha at rthand com>
Date: Tue, 23 Dec 2003 22:16:48 +0100
Local: Tues, Dec 23 2003 4:16 pm
Subject: Re: HowTo copy data between two databases using ado.net
Hi Rick,

When you insert the rows from text into dataset are you using Fill method?
If so, you should set adapter.AcceptChangesDuringFill = false.
In this case the rows will remain marked as Added.

You'll have to create an adapter that implements InsertCommand that will
store data from datatable to database.
Once you have it, just invoke its Update method on source datatable.
Ask for more details if you need to :)
--
Miha Markic - RightHand .NET consulting & development
miha at rthand com
www.rhand.com

"Rick Reynolds" <rreyno...@warrantycorp.com> wrote in message

news:eBjvlfZyDHA.1932@TK2MSFTNGP09.phx.gbl...


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2008 Google