I have a csv file i am submitting to database directly. I have tried many means but still not able to bulk copy into the database table.

I have suggestions from people. All suggestions are welcome.

This is dependent on many things, such as: What is the structure of your CSV file? What is the structure of your database? Is it all going into one table, or broken up amongst many table? Are there primary/foreign key constraints that you need to worry about?

Maybe you should start by posting the code you have tried, a small example of the input, explain how it's supposed to go in the database and explaining what went wrong.

I am using Sql Server. I just have 10 lines of data to be posted into the database table. I don't have a primary or foreign key to worry about in the table. I need some one that has been in this shoe to give me simple and plain example.

Use StreamReader to read line by line (rows), and a comma delimiter to split each line (columns).
Then you can for each row do insert or update into database, since you have all the values of a row.
Hope it helps.

read in the CSV file with

string strConn = @"Driver={Microsoft Text Driver (*.txt; *.csv)};Dbq=C:\Download Report Sheets\Monitor Detail\;Extensions=asc,csv,tab,txt";

Bind to datagrid then bulkcopy.

using (SqlBulkCopy bulkCopy = new SqlBulkCopy(thisConnection))
      {// Bulk Copy the data from the data table into the Release Table
         bulkCopy.DestinationTableName = "tbl_" + Release + "_REPLY";
         try
            {
               bulkCopy.WriteToServer(dt);
            }
         catch (Exception ex)
            {
               Console.WriteLine(ex.Message);
               thisConnection.Close();
               Console.ReadLine();
            }
         finally
            {
               thisConnection.Close();
            }
            thisReader.Close();
            thisConnection.Close();
       }
This article has been dead for over six months. Start a new discussion instead.