We help IT Professionals succeed at work.

Error with SQL line in ASP

kwitcom
kwitcom asked
on
225 Views
Last Modified: 2010-03-20
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
Comment
Watch Question

Commented:
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
   
%>

Commented:
Basically problem is because you are using variable name "sql" instead of "strSQL"

Commented:
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 & "'%"

Commented:
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 & "'"

Commented:
And I assume you have instantiate your connection object and open it :)
Commented:
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION

Author

Commented:
Thnx Found it.

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

hongjun

Gain unlimited access to on-demand training courses with an Experts Exchange subscription.

Get Access
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Empower Your Career
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.