Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using variables in a query

Status
Not open for further replies.

daph

Programmer
Jun 9, 2000
65
CA
Hi guys,

Would you please do me a favor and check if there is something wrong with the coding below? (It's just a part of it of course)

strMovieCDI = CStr(rsSQL("MOVIE_CD").Value)

intMovie_cdI = CInt(strMovieCDI)

strSQLeval = "SELECT SUM(RATING) AS SUM_RATING, COUNT(RATING) AS COUNT_RATING " & _
"FROM RATINGS_MOVIES WHERE MOVIE_CD = " & intMovie_cdI

Now, the field MOVIE_CD is an integer in my DB. I thought I took all the precautions I could, but I occasionally get this error:

Microsoft OLE DB Provider for ODBC Drivers error '80040e10'
[Microsoft][ODBC Microsoft Access Driver] Too few parameters. Expected 2.

(Please don't tell me that my fields are incorrectly spelled...I've checked that already.)

If someone could help me, I would REALLY appreciate it. I've been stumped by this one for a while now.

Thanks a lot!
Daph
 
It doesn't matter if you convert it to a string or an integer because it's going to automatically convert to a string when concatenated to the rest of the SQL string, and it will automatically be interpreted as a number when executed because it doesn't have any delimiters around it. I know you don't want to hear it, but 2 of your columns are probably misspelled. Maybe Access is case-sensitive. To debug this, add the following to your code:
Response.Write strSQLeval

Copy the output to a new query in your access database and try to run it. It should give you the same error and it will highlight what you should be looking for. Adam
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top