Insert Into .xls

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • vjainpee
    New Member
    • Apr 2008
    • 9

    Insert Into .xls

    I m new to c#

    I m trying to retrive and insert data into EXCEL from asp.net,treatin g excel as a data source

    while inserting i m facing problem because the names of columns in my .xls are having spaces in between , which are not
    permitted in C#

    this is my query
    string CommandText = "INSERT INTO [Sheet1$] (Query No, Document) values ('111', 'ABC')";

    and this is the error I m getting

    Syntax error in INSERT INTO statement.

    what to do ???????

    Thanks in advance
  • Curtis Rutland
    Recognized Expert Specialist
    • Apr 2008
    • 3264

    #2
    Put [brackets] around the column names (I think. that would work for a sql table, at least).

    Comment

    • r035198x
      MVP
      • Sep 2006
      • 13225

      #3
      Originally posted by insertAlias
      Put [brackets] around the column names (I think. that would work for a sql table, at least).
      If that doesn't work try quotes around the table name.

      Comment

      Working...