-1

i'm trying to import a .csv file using the great FileHelpers library. Doing some research most of the time i read that i should use BulkCopy to import the result into an SQL database table.

Could you please help me how to accomplish this? So far i have this:

public void ImportCSV()
        {
            string path = @"C:\...\...\...\TestCSV\";
            var engine = new FileHelperEngine<Customer>();
            var result = engine.ReadFile(path + "test3.csv");

            engine.WriteFile(path + "FileOut.csv", result);
        }

and a mapping class:

public class Customer
{
    public string Feld1;
    public string Feld2;
    public string Feld3;
    public string Feld4;
}

this works but i don't know how instead of writing the result in a new .csv file i can use an SQL table (i know this has been discussed before but i can't find a solution that's working for me so far) Thanks in advance for your help

jarlh
  • 42,561
  • 8
  • 45
  • 63
BrianF.
  • 23
  • 6

1 Answers1

1

You don't directly read it into SQL. You read it into a DataTable via the FileHelpers routines then use that DataTable to populate the database using whichever .NET provider you need to.

netniV
  • 2,328
  • 1
  • 15
  • 24