Link to home
Start Free TrialLog in
Avatar of kwitcom
kwitcomFlag for United States of America

asked on

Error with SQL line in ASP

ASP Page Error:
Microsoft OLE DB Provider for SQL Server error '80040e0c'
Command text was not set for the command object.
/Final/manual/main.asp, line 14


<%
'DECLARATIONS
dim dia, strSQL, rs, strSQL1, rs1, ordno, strSQL2, strSQL3, rs3, strSQL4, rs4, znToAdd1, strSQL5, srl, znToAdd2, nt1
dia = Date()
item = Request.QueryString("itemno")
sn = Request.QueryString("sn")

SQL = "select * from imitmidx_sql Where item_no like '"& item &"'"
set rs = Conn.Execute(strSQL)                                                                 <---- This is line #14
   
%>

Query String:
http://tmi-server:8075/Final/manual/main.asp?itemno=500-pr&sn=75

HELP
Avatar of hongjun
hongjun
Flag of Singapore image

Try this

<%
'DECLARATIONS
dim dia, strSQL, rs, strSQL1, rs1, ordno, strSQL2, strSQL3, rs3, strSQL4, rs4, znToAdd1, strSQL5, srl, znToAdd2, nt1
dia = Date()
item = Request.QueryString("itemno")
sn = Request.QueryString("sn")

strSQL = "select * from imitmidx_sql Where item_no like '" & item & "'"
set rs = Conn.Execute(strSQL)                                                                 <---- This is line #14
   
%>
Basically problem is because you are using variable name "sql" instead of "strSQL"
Since you are using Like clause, I assume you want wildcard.
So I think you should need the %

strSQL = "select * from imitmidx_sql Where item_no like '%" & item & "'%"
IF you don't need, that's you want a = match, then you should use = instead of Like

strSQL = "select * from imitmidx_sql Where item_no = '" & item & "'"
And I assume you have instantiate your connection object and open it :)
ASKER CERTIFIED SOLUTION
Avatar of hongjun
hongjun
Flag of Singapore image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of kwitcom

ASKER

Thnx Found it.
It would have been better if grade A was awarded since it pin point exactly the problem.

hongjun