views:

99

answers:

3

So there are a lot of questions regarding this method on SO, but none seem to answer my question. I firstly had an issue with the connectionstring (although it seems to work in other areas of my code correctly). This was resolved easily.

Now the issue is with a simple SELECT query via a OLEDBCommand (Text) that keeps popping up the following error?

"SELECT [Opportunity#],[BidManager],[Prob %],[Opportunity_Stage].[Opportunity_Status],[Term],[Sign Date] FROM [Sheet1$];"

No value given for one or more required parameters.

but their are no parameters????

Checked and double checked the columns names, but to no avail. Also tried removing the special characters from the column names, but still the same exception.

A: 

OleDbCommand requires two parameters, the command string you are trying to execute and the OleDbConnection itself. Are you calling it correctly?

Dim myConnection As New OleDbConnection(myConnString)
OleDbCommand myCommand = new OleDbCommand(mySelectQuery,myConnection);
Laplace
The `OleDbCommand` constructor have multiple overloads.
ho1
Except when using "OleDbCommand cmd = conn.CreateCommand();"
Jan de Jager
+1  A: 

I'd suggest trying to run SELECT * FROM [Sheet1$] that way you'll know pretty certain if it's a column issue or an issue with the rest of the code. Also, I can't check at the very moment, but are you sure there should be a ; after the select statement, isn't that just when you want to execute multiple statements?

ho1
This has been bugging me the whole day. Thanks works like a charm!!!
Jan de Jager
A: 

I've had this error with an OleDb command when my column names were incorrect.

"No value given for one or more required parameters."

I assume that the database interprets any columns names that it cannot find as parameters

Ed Vowles