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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

COUNT field incorrect or syntax error

Status
Not open for further replies.

bmpsu

Programmer
Jan 13, 2005
128
US
I've been tasked with parameterizing queries in an old classic asp site. Everything has been fine. When parameterizing this particular query, I have been getting this error description:
[Microsoft][ODBC SQL Server Driver]COUNT field incorrect or syntax error

SQL SERVER 2000.
Microsoft Visual InterDev.
This same approach has worked with other queries on the site.

Example of query:
Code:
mSQL = "SELECT var1, var2 FROM table WHERE var3='" & Session("name") & "'"
Set mRS = Server.CreateObject("ADODB.Recordset")
mRS.CursorLocation = 3
mRS.Open mSQL, Conn, 0, 1

What I changed it too:
Code:
Dim mCmdObj
Set mCmdObj = Server.CreateObject("ADODB.Command")
mCmdObj.ActiveConnection = Conn
mCmdObj.Parameters.append(mCmdObj.CreateParameter("@Name", adChar, adParamInput, 10, Session("name")))
mCmdObj.CommandType = adCmdText
mCmdObj.CommandText = "SELECT var1, var2 FROM table WHERE var3 =?"	
	
Set mRS = Server.CreateObject("ADODB.Recordset")
Set mRS = mCmdObj.Execute

Any suggestions? I'm at a lost.
 
Are you absolutely sure that your error is occuring within that code? There is no reference to COUNT at all.

The only thing I can see possible wrong with that code is the use of () around the Parameters.Append statement.

[monkey][snake] <.
 
Looks like the lunch break helped. I was missing a Metadata reference needed for this page. When I added the command object it failed because of this absence. But the code was correct. When this has happened before, I usually received a different error message.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top