0
   string strSQL = "INSERT INTO " + firstSheetName + "(Date, Market, Source, Commodity, Frequency, Price, Report_Type, MISC, Breeds, Age_Group, Gender, Grade) VALUES ('Beth', 'Hart','Beth', 'Hart','Beth', 'Hart','Beth', 'Hart','Beth', 'Hart','Beth')";

 OleDbCommand OleDbCommand = new OleDbCommand(strSQL, oconn);

   OleDbCommand.ExecuteNonQuery();

what might be the problem ?

1 Answer 1

2

You need a space after "INSERT INTO " + firstSheetName + "(Date,

to

"INSERT INTO " + firstSheetName + " (Date,

Another thing that I have noticed is that you have 12 column values and only 11 data values. You'll need to add the 12th data value.

Sign up to request clarification or add additional context in comments.

6 Comments

no this also doesn't solves the problem . $ are allowed in the name?
Change your query to "INSERT INTO [" + firstSheetName + "] (Date, etc.
Surely INTO [" + firstSheetName + "$]
@Remou: I'm under the impression that firstSheetName equals something like MySheet$
Good point, but I suspect it does not. (I should have added an @ for the OP, because the comment was much more meant for @mazhar)
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.