将数据从一个数据表发送到另一个

时间:2013-12-16 17:21:45

标签: sql oracle

我正在尝试使用批量复制将数据从sql发送到oracle。 这是代码

            string sqldb = "server=DOR-SQLTEST\\DORSQLSERVER;" + "initial catalog=RD2KTEST;" + "user id=amehra;" + "password=Research@322";
            SqlConnection sqlconn = new SqlConnection(sqldb);
            sqlconn.Open();


            string sqlstring="select TOP 10 POSITION_ID, POSITION_DESC  from T_CD_POSITION";

            SqlCommand scmd = new SqlCommand(sqlstring, sqlconn);
            SqlDataReader reader = scmd.ExecuteReader();


            while(reader.Read())
            {
                 Console.WriteLine("entered to write to oracle.......\n\n");

                 string oradb = "Data Source=UHAMPTST;user id=ocg_de;password=rd2k";
                OracleConnection oraconn = new OracleConnection(oradb);
                oraconn.Open();
                Console.WriteLine("orca conn established....");


                using( OracleBulkCopy orca_bulk_copy = new OracleBulkCopy(oraconn))
                 {
                    orca_bulk_copy.DestinationTableName = "t_test_postion";

                    orca_bulk_copy.WriteToServer(reader);//line 38

                    orca_bulk_copy.Close();
                    orca_bulk_copy.Dispose();
                 }

            }
        }

    }
}

由于Oracle异常发生,我在第38行遇到错误。 请妥善解决问题

0 个答案:

没有答案