C# : transfer data from one database to other

  • Thread starter Thread starter sravan_reddy001
  • Start date Start date
S

sravan_reddy001

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;
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
}
 
Hi here,

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

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

--
cheers,

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;
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)?
 
Of course.

--
cheers,
RL
sravan_reddy001 said:
Hi here,

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

--
cheers,

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;
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)?
 
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.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

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;
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
}
 

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

Back
Top