Results 1 to 4 of 4

Thread: ASP error

  1. #1
    Join Date
    Feb 2004
    Posts
    3

    Unanswered: 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 >>.

  2. #2
    Join Date
    Dec 2003
    Posts
    454
    What is >> in the code >>Set RS=MyConn.Execute(SQL)?

  3. #3
    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

  4. #4
    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •