Having datatype problems when passing OleDbDatareader to SQLBULKCOPY (SQL SERVER 2005) RRS feed

  • Question

  • I am bulk inserting records from a CSV File using the SQLBULKCOPY class. The SQLBULKCOPY.WriteToServer method allows IDataReader, Datatable, or DataSets only.  I can only use a class referencing the IDataReader interface only. I am using OleDeDataReader, but I am having problems adding records with different datatypes.


    Here is some of the code I'm using:

    string sConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=Destination;Extended Properties=\"Text;HDR=No\"";

    OleDbConnection conn = new OleDbConnection(sConnectionString);

    OleDbCommand cmd = new OleDbCommand("SELECT * FROM ItemSheet.csv", conn);


    SqlBulkCopy bulkCopy = new SqlBulkCopy(DB);

    bulkCopy.DestinationTableName = "dbo.ITEMS";



    Does anyone have any suggestions about how I can solve my problem?

    Thursday, November 1, 2007 3:04 PM