insert data between two different database

luquantes

New member
Joined
Oct 17, 2005
Messages
1
Programming Experience
1-3
i have a code on CSharp

OleDbDataAdapter da1 = new OleDbDataAdapter("select * from Order",conn1);
OleDbDataAdapter da2 = new OleDbDataAdapter("select * from Order",conn2);

System.Data.DataSet ds1=new DataSet("ds1");
da1.Fill(ds1);
System.Data.DataSet ds2=new DataSet("ds2");
da2.Fill(ds2);
DataRow dr = ds2.Tables[0].NewRow();

for (int i=0;i < ds1.Tables[0].Rows.Count;i++)
{
dr.ItemArray = ds1.Tables[0].Rows.ItemArray;
ds2.Tables[0].Rows.Add(dr);
da2.Update(ds2);
}

There are two Order tables in different databases. One of DB is oracle other one is SQL Server.

mssql.Order -> oracle.Order
they have same field names. But this code says

"Update requires a valid InsertCommand when passed DataRow collection with new rows."

What's wrong?
 
Make sure that the InsertCommand of your dataadapter da2 is declared and also that is a valid insert command.

You can do this by:
1. Configuring the dataset using the wizard
2. Set the property on the adapter da2.InsertCommand = "Insert into ..."
 
Back
Top