By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,854 Members | 2,015 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,854 IT Pros & Developers. It's quick & easy.

C# : transfer data from one database to other

P: n/a
I had created an appication that serves as an address book

i used the SQL server 2000 as the database to store the contacts;
its only a single table that contains enitre details

now i thought of transferring the entire details from the table(name :
addressbook) in sql 2000 to the ms access table(table name :
addressbook)

i had provided the same column names and their types (all "varchar" in
SQL and all "text" in MS Access)

how to transfer the data table
i tried disconnected architecture, i do accpet connnected one also

the code that troubles me is :

drs = sqlds.Tables["ab"].NewRow();
drm = msads.Tables["ab"].NewRow();
for (int i = 0; i < sqlds.Tables["ab"].Rows.Count; i++)
{
drs = sqlds.Tables["ab"].Rows[i];
drm=drs;
msads.Tables["ab"].Rows.Add(drm);
msada.Update(msads, "ab"); //---------------this
line is prob, it is saying that
// this row already belongs
to other table

// i used two datasets each for SQL and MSA and same table name in
both
}

Jun 6 '07 #1
Share this Question
Share on Google+
4 Replies


P: n/a
Hi here,

Something wrong with your server's export data and the DTS?

--
cheers,
RL
"sravan_reddy001" <sr*************@gmail.comwrote in message
news:11**********************@n15g2000prd.googlegr oups.com...
>I had created an appication that serves as an address book

i used the SQL server 2000 as the database to store the contacts;
its only a single table that contains enitre details

now i thought of transferring the entire details from the table(name :
addressbook) in sql 2000 to the ms access table(table name :
addressbook)

i had provided the same column names and their types (all "varchar" in
SQL and all "text" in MS Access)

how to transfer the data table
i tried disconnected architecture, i do accpet connnected one also

the code that troubles me is :

drs = sqlds.Tables["ab"].NewRow();
drm = msads.Tables["ab"].NewRow();
for (int i = 0; i < sqlds.Tables["ab"].Rows.Count; i++)
{
drs = sqlds.Tables["ab"].Rows[i];
drm=drs;
msads.Tables["ab"].Rows.Add(drm);
msada.Update(msads, "ab"); //---------------this
line is prob, it is saying that
// this row already belongs
to other table

// i used two datasets each for SQL and MSA and same table name in
both
}

Jun 6 '07 #2

P: n/a
On Jun 6, 7:34 pm, "Egghead" <robertlo@NO_SHAW.CAwrote:
Hi here,

Something wrong with your server's export data and the DTS?

--
cheers,
RL"sravan_reddy001" <sravanganta2...@gmail.comwrote in message

news:11**********************@n15g2000prd.googlegr oups.com...
I had created an appication that serves as an address book
i used the SQL server 2000 as the database to store the contacts;
its only a single table that contains enitre details
now i thought of transferring the entire details from the table(name :
addressbook) in sql 2000 to the ms access table(table name :
addressbook)
i had provided the same column names and their types (all "varchar" in
SQL and all "text" in MS Access)
how to transfer the data table
i tried disconnected architecture, i do accpet connnected one also
the code that troubles me is :
drs = sqlds.Tables["ab"].NewRow();
drm = msads.Tables["ab"].NewRow();
for (int i = 0; i < sqlds.Tables["ab"].Rows.Count; i++)
{
drs = sqlds.Tables["ab"].Rows[i];
drm=drs;
msads.Tables["ab"].Rows.Add(drm);
msada.Update(msads, "ab"); //---------------this
line is prob, it is saying that
// this row already belongs
to other table
// i used two datasets each for SQL and MSA and same table name in
both
}
is this possible to transfer the data from one table to the other in
different databases(sql and msaccess)?

Jun 6 '07 #3

P: n/a
Of course.

--
cheers,
RL
"sravan_reddy001" <sr*************@gmail.comwrote in message
news:11**********************@d30g2000prg.googlegr oups.com...
On Jun 6, 7:34 pm, "Egghead" <robertlo@NO_SHAW.CAwrote:
>Hi here,

Something wrong with your server's export data and the DTS?

--
cheers,
RL"sravan_reddy001" <sravanganta2...@gmail.comwrote in message

news:11**********************@n15g2000prd.googleg roups.com...
>I had created an appication that serves as an address book
i used the SQL server 2000 as the database to store the contacts;
its only a single table that contains enitre details
now i thought of transferring the entire details from the table(name :
addressbook) in sql 2000 to the ms access table(table name :
addressbook)
i had provided the same column names and their types (all "varchar" in
SQL and all "text" in MS Access)
how to transfer the data table
i tried disconnected architecture, i do accpet connnected one also
the code that troubles me is :
drs = sqlds.Tables["ab"].NewRow();
drm = msads.Tables["ab"].NewRow();
for (int i = 0; i < sqlds.Tables["ab"].Rows.Count; i++)
{
drs = sqlds.Tables["ab"].Rows[i];
drm=drs;
msads.Tables["ab"].Rows.Add(drm);
msada.Update(msads, "ab"); //---------------this
line is prob, it is saying that
// this row already belongs
to other table
// i used two datasets each for SQL and MSA and same table name in
both
}

is this possible to transfer the data from one table to the other in
different databases(sql and msaccess)?

Jun 6 '07 #4

P: n/a
bob
Hi,
Basic problem is that you are pointing the drm Access row variable at
the drs SQL row variable.
What you need to do is read each field from the drs row and write it
to its corresponding field in the drm row.
One way of doing this;
In your loop:
make use of the item array property of the sql datarow and the
MSAccess data row

object[] arS;
drm = msads.Tables["ab"].NewRow();
for (int i = 0; i < sqlds.Tables["ab"].Rows.Count; i++)
{
arS=sqlds.Tables["ab"].Rows[i].ItemArray;
drm.ItemArray=arS;
msads.Tables["ab"].Rows.Add(drm);
msada.Update(msads, "ab"); //---------------this

The above 'should' work.
I don't think you will need to iterate through the array doing
individual member assignments but I am not sure.
hth
Bob

On Wed, 06 Jun 2007 13:50:58 -0000, sravan_reddy001
<sr*************@gmail.comwrote:
>I had created an appication that serves as an address book

i used the SQL server 2000 as the database to store the contacts;
its only a single table that contains enitre details

now i thought of transferring the entire details from the table(name :
addressbook) in sql 2000 to the ms access table(table name :
addressbook)

i had provided the same column names and their types (all "varchar" in
SQL and all "text" in MS Access)

how to transfer the data table
i tried disconnected architecture, i do accpet connnected one also

the code that troubles me is :

drs = sqlds.Tables["ab"].NewRow();
drm = msads.Tables["ab"].NewRow();
for (int i = 0; i < sqlds.Tables["ab"].Rows.Count; i++)
{
drs = sqlds.Tables["ab"].Rows[i];
drm=drs;
msads.Tables["ab"].Rows.Add(drm);
msada.Update(msads, "ab"); //---------------this
line is prob, it is saying that
// this row already belongs
to other table

// i used two datasets each for SQL and MSA and same table name in
both
}
Jun 7 '07 #5

This discussion thread is closed

Replies have been disabled for this discussion.