If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ASP > ASP error

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 02-12-04, 01:23
zottis zottis is offline
Registered User
 
Join Date: Feb 2004
Posts: 3
ASP error

hello!im trying to search the databse and this is my asp code:

<%@Language=VBScript%>
<% Response.Buffer = True %>
<html>
<head><title></title></head>
<body>
<%
Dim MyConn, SQL, RS, srchval, i

'srchval = Replace(Request.Form("searchvalue"), "'", "''")
'srchall = Request.Form("all")

Set MyConn=Server.CreateObject("ADODB.Connection")
Set RS=Server.CreateObject("ADODB.RecordSet")
dbpath = server.mappath("First.mdb")
MyConn.mode = admodereadwrite
MyConn.Open "Provider = Microsoft.Jet.OLEDB.4.0; Data source = " & dbpath
RS.Open "Select * From food", MyConn





If request.form("checkbox1") = Sugar Then
SQL = "Select * From food Where ItemName Like '%"&request.form("checkbox1")&"%'"

End If


>>Set RS=MyConn.Execute(SQL)

If request.form("checkbox1") <> "" Then
If RS.BOF And RS.EOF Then
Response.Write "No Records Found."
Else
Response.Write "<center><table border=""1""><tr>"
For i = 0 To RS.Fields.Count - 1
Response.Write "<th>" & RS(i).Name & "</th>"
Next
Response.Write "</tr>"
While Not RS.EOF
Response.Write "<tr>"
For i = 0 To RS.Fields.Count - 1
Response.Write "<td>" & RS(i).Value & "</td>"
Next
Response.Write "</tr>"
RS.MoveNext
Wend
Response.Write "</table>"
End If
'Else
'Response.Redirect "search.asp"
End If

RS.Close
MyConn.Close
Set RS = Nothing
Set MyConn = Nothing
%>


</body>
</html>
im getting this error:Microsoft JET Database Engine (0x80040E0C)
Command text was not set for the command object.at the line with >>.
Reply With Quote
  #2 (permalink)  
Old 02-12-04, 12:33
gyuan gyuan is offline
Registered User
 
Join Date: Dec 2003
Posts: 454
What is >> in the code >>Set RS=MyConn.Execute(SQL)?
Reply With Quote
  #3 (permalink)  
Old 02-12-04, 22:38
zakyk zakyk is offline
Registered User
 
Join Date: Mar 2003
Posts: 32
u open 2 statment for generate 1 function..i think u should deleted this line if u prefer using the statment the other one :

RS.Open "Select * From food", MyConn
Reply With Quote
  #4 (permalink)  
Old 02-12-04, 22:50
gyuan gyuan is offline
Registered User
 
Join Date: Dec 2003
Posts: 454
If you need to open two Record Sets, you can not use the same the same instance of the object, i.e., RS in your code. You can use

Set RS1=MyConn.Execute(SQL)

instead of

Set RS=MyConn.Execute(SQL)

since RS is not closed.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On