Return value

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • solomon_13000

    Return value

    The code bellow functions well. However if I want to obtain a return
    value using the code bellow, how is it done?

    <%
    Sub RunQueryString (pSQL,parms)
    on error resume next
    Set conn = Server.CreateOb ject("ADODB.Con nection")
    conn.open "Provider=Micro soft.Jet.OLEDB. 4.0;Data Source=" &
    Server.MapPath( "/db/upload/stelladb.mdb") & ";"
    Set cmd = Server.CreateOb ject("adodb.com mand")
    With cmd
    ..CommandText = pSQL
    ..CommandType = 1
    set .ActiveConnecti on = conn
    err.clear
    ..Execute ,parms,128
    if Err.number <> 0 then
    Response.Write( Err.number & ":" & Err.Description & "
    ")
    end if
    on Error goto 0
    End with
    conn.close
    Set conn = nothing
    End Sub
    %>


    <%
    if Request.QuerySt ring("Action") = 1 then
    username = Trim(request.fo rm("username") )
    password = Trim(request.fo rm("password") )
    if username <> "" and password <> "" then
    arParms = Array(username, password)
    sql = "SELECT Count(*) FROM Account WHERE username=? AND password=?"
    RunQueryString sql, arParms
    end if
    end if
    %>

  • solomon_13000

    #2
    Re: Return value

    I am trying to obtain a return value for the sql statement bellow:

    sql = "SELECT Count(*) FROM Account WHERE username=? AND password=?"

    which can be found on the code which I have posted.


    solomon_13000 wrote:[color=blue]
    > The code bellow functions well. However if I want to obtain a return
    > value using the code bellow, how is it done?
    >
    > <%
    > Sub RunQueryString (pSQL,parms)
    > on error resume next
    > Set conn = Server.CreateOb ject("ADODB.Con nection")
    > conn.open "Provider=Micro soft.Jet.OLEDB. 4.0;Data Source=" &
    > Server.MapPath( "/db/upload/stelladb.mdb") & ";"
    > Set cmd = Server.CreateOb ject("adodb.com mand")
    > With cmd
    > .CommandText = pSQL
    > .CommandType = 1
    > set .ActiveConnecti on = conn
    > err.clear
    > .Execute ,parms,128
    > if Err.number <> 0 then
    > Response.Write( Err.number & ":" & Err.Description & "
    > ")
    > end if
    > on Error goto 0
    > End with
    > conn.close
    > Set conn = nothing
    > End Sub
    > %>
    >
    >
    > <%
    > if Request.QuerySt ring("Action") = 1 then
    > username = Trim(request.fo rm("username") )
    > password = Trim(request.fo rm("password") )
    > if username <> "" and password <> "" then
    > arParms = Array(username, password)
    > sql = "SELECT Count(*) FROM Account WHERE username=? AND password=?"
    > RunQueryString sql, arParms
    > end if
    > end if
    > %>[/color]

    Comment

    • solomon_13000

      #3
      Re: Return value

      I did this:

      <%
      Sub RunQueryString (pSQL,parms)
      Set rs = Server.CreateOb ject("ADODB.Rec ordset")
      ..Execute rs,parms,128
      End Sub
      %>

      <%
      sql = "SELECT username,passwo rd FROM Account WHERE username=? AND
      password=?"
      RunQueryString sql, arParms
      response.write rs("username")
      %>

      the results was HTTP:500 Internal server error.

      solomon_13000 wrote:[color=blue]
      > The code bellow functions well. However if I want to obtain a return
      > value using the code bellow, how is it done?
      >
      > <%
      > Sub RunQueryString (pSQL,parms)
      > on error resume next
      > Set conn = Server.CreateOb ject("ADODB.Con nection")
      > conn.open "Provider=Micro soft.Jet.OLEDB. 4.0;Data Source=" &
      > Server.MapPath( "/db/upload/stelladb.mdb") & ";"
      > Set cmd = Server.CreateOb ject("adodb.com mand")
      > With cmd
      > .CommandText = pSQL
      > .CommandType = 1
      > set .ActiveConnecti on = conn
      > err.clear
      > .Execute ,parms,128
      > if Err.number <> 0 then
      > Response.Write( Err.number & ":" & Err.Description & "
      > ")
      > end if
      > on Error goto 0
      > End with
      > conn.close
      > Set conn = nothing
      > End Sub
      > %>
      >
      >
      > <%
      > if Request.QuerySt ring("Action") = 1 then
      > username = Trim(request.fo rm("username") )
      > password = Trim(request.fo rm("password") )
      > if username <> "" and password <> "" then
      > arParms = Array(username, password)
      > sql = "SELECT Count(*) FROM Account WHERE username=? AND password=?"
      > RunQueryString sql, arParms
      > end if
      > end if
      > %>[/color]

      Comment

      • solomon_13000

        #4
        Re: Return value

        I have even tried the following method:

        Sub RunQueryString (pSQL,parms)
        Set rs = Server.CreateOb ject("ADODB.Rec ordset")
        Dim p
        set rs = .Execute(p,parm s,128)
        End Sub

        and I am getting the following error:

        Type: Nothing

        Microsoft VBScript runtime error '800a01a8'

        Object required


        solomon_13000 wrote:[color=blue]
        > The code bellow functions well. However if I want to obtain a return
        > value using the code bellow, how is it done?
        >
        > <%
        > Sub RunQueryString (pSQL,parms)
        > on error resume next
        > Set conn = Server.CreateOb ject("ADODB.Con nection")
        > conn.open "Provider=Micro soft.Jet.OLEDB. 4.0;Data Source=" &
        > Server.MapPath( "/db/upload/stelladb.mdb") & ";"
        > Set cmd = Server.CreateOb ject("adodb.com mand")
        > With cmd
        > .CommandText = pSQL
        > .CommandType = 1
        > set .ActiveConnecti on = conn
        > err.clear
        > .Execute ,parms,128
        > if Err.number <> 0 then
        > Response.Write( Err.number & ":" & Err.Description & "
        > ")
        > end if
        > on Error goto 0
        > End with
        > conn.close
        > Set conn = nothing
        > End Sub
        > %>
        >
        >
        > <%
        > if Request.QuerySt ring("Action") = 1 then
        > username = Trim(request.fo rm("username") )
        > password = Trim(request.fo rm("password") )
        > if username <> "" and password <> "" then
        > arParms = Array(username, password)
        > sql = "SELECT Count(*) FROM Account WHERE username=? AND password=?"
        > RunQueryString sql, arParms
        > end if
        > end if
        > %>[/color]

        Comment

        • Mike Brind

          #5
          Re: Return value


          solomon_13000 wrote:[color=blue]
          > The code bellow functions well. However if I want to obtain a return
          > value using the code bellow, how is it done?
          >
          > <%
          > Sub RunQueryString (pSQL,parms)
          > on error resume next
          > Set conn = Server.CreateOb ject("ADODB.Con nection")
          > conn.open "Provider=Micro soft.Jet.OLEDB. 4.0;Data Source=" &
          > Server.MapPath( "/db/upload/stelladb.mdb") & ";"
          > Set cmd = Server.CreateOb ject("adodb.com mand")
          > With cmd
          > .CommandText = pSQL
          > .CommandType = 1
          > set .ActiveConnecti on = conn
          > err.clear
          > .Execute ,parms,128
          > if Err.number <> 0 then
          > Response.Write( Err.number & ":" & Err.Description & "
          > ")
          > end if
          > on Error goto 0
          > End with
          > conn.close
          > Set conn = nothing
          > End Sub
          > %>
          >
          >
          > <%
          > if Request.QuerySt ring("Action") = 1 then
          > username = Trim(request.fo rm("username") )
          > password = Trim(request.fo rm("password") )
          > if username <> "" and password <> "" then
          > arParms = Array(username, password)
          > sql = "SELECT Count(*) FROM Account WHERE username=? AND password=?"
          > RunQueryString sql, arParms
          > end if
          > end if
          > %>[/color]

          You can't obtain a return value from a subroutine, so from the
          additional code you have posted, I assume you want to check the value
          of "sql". If that's the case, just Response.Write sql before
          RunQueryString sql, arParms.

          --
          Mike Brind

          Comment

          • solomon_13000

            #6
            Re: Return value

            Actually I intend to obtain a return value using the statement bellow:

            sql = "SELECT Count(*) FROM Account WHERE username=? AND password=?"


            solomon_13000 wrote:[color=blue]
            > The code bellow functions well. However if I want to obtain a return
            > value using the code bellow, how is it done?
            >
            > <%
            > Sub RunQueryString (pSQL,parms)
            > on error resume next
            > Set conn = Server.CreateOb ject("ADODB.Con nection")
            > conn.open "Provider=Micro soft.Jet.OLEDB. 4.0;Data Source=" &
            > Server.MapPath( "/db/upload/stelladb.mdb") & ";"
            > Set cmd = Server.CreateOb ject("adodb.com mand")
            > With cmd
            > .CommandText = pSQL
            > .CommandType = 1
            > set .ActiveConnecti on = conn
            > err.clear
            > .Execute ,parms,128
            > if Err.number <> 0 then
            > Response.Write( Err.number & ":" & Err.Description & "
            > ")
            > end if
            > on Error goto 0
            > End with
            > conn.close
            > Set conn = nothing
            > End Sub
            > %>
            >
            >
            > <%
            > if Request.QuerySt ring("Action") = 1 then
            > username = Trim(request.fo rm("username") )
            > password = Trim(request.fo rm("password") )
            > if username <> "" and password <> "" then
            > arParms = Array(username, password)
            > sql = "SELECT Count(*) FROM Account WHERE username=? AND password=?"
            > RunQueryString sql, arParms
            > end if
            > end if
            > %>[/color]

            Comment

            • solomon_13000

              #7
              Re: Return value

              This is the complete code In which I intend to obtain a return value. I
              am getting the following error:


              Microsoft VBScript runtime error '800a01a8'

              Object required

              and the error is pointing to response.write rs(0)


              <%
              Sub RunQueryString (pSQL,parms)
              on error resume next
              Set conn = Server.CreateOb ject("ADODB.Con nection")
              Set rs = Server.CreateOb ject("ADODB.Rec ordset")
              conn.open "Provider=Micro soft.Jet.OLEDB. 4.0;Data Source=" &
              Server.MapPath( "/db/upload/stelladb.mdb") & ";"
              Set cmd = Server.CreateOb ject("adodb.com mand")
              With cmd
              .CommandText = pSQL
              .CommandType = 1
              set .ActiveConnecti on = conn
              err.clear
              Dim banana
              Set rs = .Execute(banana ,parms,128)
              if Err.number <> 0 then
              Response.Write( Err.number & ":" & Err.Description &
              "<br>")
              end if
              on Error goto 0
              End with
              conn.close
              Set conn = nothing
              End Sub
              %>

              <%
              if Request.QuerySt ring("Action") = 1 then
              username = Trim(request.fo rm("username") )
              password = Trim(request.fo rm("password") )
              if username <> "" and password <> "" then
              arParms = Array(username, password)
              sql = "SELECT Count(*) FROM Account WHERE username=? AND
              password=?"
              RunQueryString sql, arParms
              response.write rs(0)
              end if
              end if
              %>




              solomon_13000 wrote:[color=blue]
              > The code bellow functions well. However if I want to obtain a return
              > value using the code bellow, how is it done?
              >
              > <%
              > Sub RunQueryString (pSQL,parms)
              > on error resume next
              > Set conn = Server.CreateOb ject("ADODB.Con nection")
              > conn.open "Provider=Micro soft.Jet.OLEDB. 4.0;Data Source=" &
              > Server.MapPath( "/db/upload/stelladb.mdb") & ";"
              > Set cmd = Server.CreateOb ject("adodb.com mand")
              > With cmd
              > .CommandText = pSQL
              > .CommandType = 1
              > set .ActiveConnecti on = conn
              > err.clear
              > .Execute ,parms,128
              > if Err.number <> 0 then
              > Response.Write( Err.number & ":" & Err.Description & "
              > ")
              > end if
              > on Error goto 0
              > End with
              > conn.close
              > Set conn = nothing
              > End Sub
              > %>
              >
              >
              > <%
              > if Request.QuerySt ring("Action") = 1 then
              > username = Trim(request.fo rm("username") )
              > password = Trim(request.fo rm("password") )
              > if username <> "" and password <> "" then
              > arParms = Array(username, password)
              > sql = "SELECT Count(*) FROM Account WHERE username=? AND password=?"
              > RunQueryString sql, arParms
              > end if
              > end if
              > %>[/color]

              Comment

              • Martin Walke

                #8
                Re: Return value

                Ah - just spotted that you are using the 'with' construct!

                The error is complaining that rs doesn't exist or not initialised. As far as
                i can see, option 128 (which is 80H) is adExecuteNoReco rds.

                The clue may be in that!

                Martin

                "solomon_13 000" <solomon_13000@ yahoo.com> wrote in message
                news:1150379037 .778549.254000@ y41g2000cwy.goo glegroups.com.. .[color=blue]
                > This is the complete code In which I intend to obtain a return value. I
                > am getting the following error:
                >
                >
                > Microsoft VBScript runtime error '800a01a8'
                >
                > Object required
                >
                > and the error is pointing to response.write rs(0)
                >
                >
                > <%
                > Sub RunQueryString (pSQL,parms)
                > on error resume next
                > Set conn = Server.CreateOb ject("ADODB.Con nection")
                > Set rs = Server.CreateOb ject("ADODB.Rec ordset")
                > conn.open "Provider=Micro soft.Jet.OLEDB. 4.0;Data Source=" &
                > Server.MapPath( "/db/upload/stelladb.mdb") & ";"
                > Set cmd = Server.CreateOb ject("adodb.com mand")
                > With cmd
                > .CommandText = pSQL
                > .CommandType = 1
                > set .ActiveConnecti on = conn
                > err.clear
                > Dim banana
                > Set rs = .Execute(banana ,parms,128)
                > if Err.number <> 0 then
                > Response.Write( Err.number & ":" & Err.Description &
                > "<br>")
                > end if
                > on Error goto 0
                > End with
                > conn.close
                > Set conn = nothing
                > End Sub
                > %>
                >
                > <%
                > if Request.QuerySt ring("Action") = 1 then
                > username = Trim(request.fo rm("username") )
                > password = Trim(request.fo rm("password") )
                > if username <> "" and password <> "" then
                > arParms = Array(username, password)
                > sql = "SELECT Count(*) FROM Account WHERE username=? AND
                > password=?"
                > RunQueryString sql, arParms
                > response.write rs(0)
                > end if
                > end if
                > %>
                >
                >
                >
                >
                > solomon_13000 wrote:[color=green]
                >> The code bellow functions well. However if I want to obtain a return
                >> value using the code bellow, how is it done?
                >>
                >> <%
                >> Sub RunQueryString (pSQL,parms)
                >> on error resume next
                >> Set conn = Server.CreateOb ject("ADODB.Con nection")
                >> conn.open "Provider=Micro soft.Jet.OLEDB. 4.0;Data Source=" &
                >> Server.MapPath( "/db/upload/stelladb.mdb") & ";"
                >> Set cmd = Server.CreateOb ject("adodb.com mand")
                >> With cmd
                >> .CommandText = pSQL
                >> .CommandType = 1
                >> set .ActiveConnecti on = conn
                >> err.clear
                >> .Execute ,parms,128
                >> if Err.number <> 0 then
                >> Response.Write( Err.number & ":" & Err.Description & "
                >> ")
                >> end if
                >> on Error goto 0
                >> End with
                >> conn.close
                >> Set conn = nothing
                >> End Sub
                >> %>
                >>
                >>
                >> <%
                >> if Request.QuerySt ring("Action") = 1 then
                >> username = Trim(request.fo rm("username") )
                >> password = Trim(request.fo rm("password") )
                >> if username <> "" and password <> "" then
                >> arParms = Array(username, password)
                >> sql = "SELECT Count(*) FROM Account WHERE username=? AND password=?"
                >> RunQueryString sql, arParms
                >> end if
                >> end if
                >> %>[/color]
                >[/color]


                Comment

                • Martin Walke

                  #9
                  Re: Return value

                  Hi Solomon,

                  The problem (in all your posts) is that you're not referencing the
                  connection object when you use the execute statement. You must precede the
                  statement with your connection i.e.

                  Set rs = conn.Execute(ba nana,parms,128)

                  or surround it with a 'with' construct

                  with conn
                  Set rs = .Execute(banana ,parms,128)
                  end with

                  I would also recommend you use the constant values for the "options"
                  parameter (adCmd...) as who knows what 128 means

                  HTH
                  Martin

                  "solomon_13 000" <solomon_13000@ yahoo.com> wrote in message
                  news:1150379037 .778549.254000@ y41g2000cwy.goo glegroups.com.. .[color=blue]
                  > This is the complete code In which I intend to obtain a return value. I
                  > am getting the following error:
                  >
                  >
                  > Microsoft VBScript runtime error '800a01a8'
                  >
                  > Object required
                  >
                  > and the error is pointing to response.write rs(0)
                  >
                  >
                  > <%
                  > Sub RunQueryString (pSQL,parms)
                  > on error resume next
                  > Set conn = Server.CreateOb ject("ADODB.Con nection")
                  > Set rs = Server.CreateOb ject("ADODB.Rec ordset")
                  > conn.open "Provider=Micro soft.Jet.OLEDB. 4.0;Data Source=" &
                  > Server.MapPath( "/db/upload/stelladb.mdb") & ";"
                  > Set cmd = Server.CreateOb ject("adodb.com mand")
                  > With cmd
                  > .CommandText = pSQL
                  > .CommandType = 1
                  > set .ActiveConnecti on = conn
                  > err.clear
                  > Dim banana
                  > Set rs = .Execute(banana ,parms,128)
                  > if Err.number <> 0 then
                  > Response.Write( Err.number & ":" & Err.Description &
                  > "<br>")
                  > end if
                  > on Error goto 0
                  > End with
                  > conn.close
                  > Set conn = nothing
                  > End Sub
                  > %>
                  >
                  > <%
                  > if Request.QuerySt ring("Action") = 1 then
                  > username = Trim(request.fo rm("username") )
                  > password = Trim(request.fo rm("password") )
                  > if username <> "" and password <> "" then
                  > arParms = Array(username, password)
                  > sql = "SELECT Count(*) FROM Account WHERE username=? AND
                  > password=?"
                  > RunQueryString sql, arParms
                  > response.write rs(0)
                  > end if
                  > end if
                  > %>
                  >
                  >
                  >
                  >
                  > solomon_13000 wrote:[color=green]
                  >> The code bellow functions well. However if I want to obtain a return
                  >> value using the code bellow, how is it done?
                  >>
                  >> <%
                  >> Sub RunQueryString (pSQL,parms)
                  >> on error resume next
                  >> Set conn = Server.CreateOb ject("ADODB.Con nection")
                  >> conn.open "Provider=Micro soft.Jet.OLEDB. 4.0;Data Source=" &
                  >> Server.MapPath( "/db/upload/stelladb.mdb") & ";"
                  >> Set cmd = Server.CreateOb ject("adodb.com mand")
                  >> With cmd
                  >> .CommandText = pSQL
                  >> .CommandType = 1
                  >> set .ActiveConnecti on = conn
                  >> err.clear
                  >> .Execute ,parms,128
                  >> if Err.number <> 0 then
                  >> Response.Write( Err.number & ":" & Err.Description & "
                  >> ")
                  >> end if
                  >> on Error goto 0
                  >> End with
                  >> conn.close
                  >> Set conn = nothing
                  >> End Sub
                  >> %>
                  >>
                  >>
                  >> <%
                  >> if Request.QuerySt ring("Action") = 1 then
                  >> username = Trim(request.fo rm("username") )
                  >> password = Trim(request.fo rm("password") )
                  >> if username <> "" and password <> "" then
                  >> arParms = Array(username, password)
                  >> sql = "SELECT Count(*) FROM Account WHERE username=? AND password=?"
                  >> RunQueryString sql, arParms
                  >> end if
                  >> end if
                  >> %>[/color]
                  >[/color]


                  Comment

                  Working...