Bulk Insert In C#.net?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • arunsan3
    New Member
    • Apr 2010
    • 4

    Bulk Insert In C#.net?

    cmd = new SqlCommand("BUL K INSERT Sam FROM 'c:\b1.txt' WITH (FIELDTERMINATO R =',',ROWTERMINA TOR = '\n')", con);
    cmd.ExecuteNonQ uery();

    it showing error like this:
    "Cannot use empty object or column names. Use a single space if necessary."
    Please Help me.
  • Monomachus
    Recognized Expert New Member
    • Apr 2008
    • 127

    #2
    Originally posted by arunsan3
    cmd = new SqlCommand("BUL K INSERT Sam FROM 'c:\b1.txt' WITH (FIELDTERMINATO R =',',ROWTERMINA TOR = '\n')", con);
    cmd.ExecuteNonQ uery();

    it showing error like this:
    "Cannot use empty object or column names. Use a single space if necessary."
    Please Help me.
    Hi
    Try to use SqlBulkCopy class
    Here is the link to an example with some explanations:
    Bulk insert into SQL from C# App
    And the MSDN article is here Bulk Copy operations in SQL Server.

    Comment

    • stoogots2
      New Member
      • Sep 2007
      • 77

      #3
      FYI, the SQLBulkCopy is very similar in performance to the BULK INSERT statement you specify above IF you set the Table Lock on.

      Comment

      Working...