none
copy dataset1(db1) to dataset2(db2) and send back dataset2 to db2. RRS feed

  • Question

  • hi,

     

    i am trying to achieve this:

    i have 2 different databses. i need to get data from one databse (for eg. in a datset), copy it into another dateset (pointing to the second database), make changes and send the results back to second databse.

     

    i tried to use the ds.copy() method, using something like this:

     

                    DataSet ds;
                    strConn = " first databse";
                    strSQL = " Select * from table1 "; // in first database

          OracleConnection connection = new OracleConnection(strConn);
          OracleDataAdapter adapter = new OracleDataAdapter();

          adapter.SelectCommand = new OracleCommand(strSQL, connection);
          adapter.Fill(ds, "MyTable");

                     DataSet ds1 = new DataSet();
              

                     ds1 = ds.Copy();
               

                     DataTable dt = new DataTable("T1");
                     dt = ds1.Tables[0];

                     strConn1 = " second databse";
                     OracleConnection connection = new OracleConnection(strConn1);
                     OracleDataAdapter adapter1 = new OracleDataAdapter();

                     adapter1.SelectCommand= new OracleCommand("" Select * from table2 where 1=2 "; ", connection); // in second database


                     adapter1.Fill(dt);
                     adapter1.Update(dt);
     

    the dicey part is when i am trying to assign a select command to adapter1 by saying "create an SQL with no rows (1=2) ", but then fill the adpater1 from the dt obtained from dataset1. All this so that i can avoid a row by row insert into db2, and send the ds in one shot (bulk, using Oracle only.)

    Maybe theres another approach to do bulk insert in Oracle(using c# ) ? what do you guys think??  

    Thursday, August 16, 2007 4:44 PM