By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,223 Members | 1,392 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,223 IT Pros & Developers. It's quick & easy.

Return value

P: n/a
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.CreateObject("ADODB.Connection")
conn.open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" &
Server.MapPath("/db/upload/stelladb.mdb") & ";"
Set cmd = Server.CreateObject("adodb.command")
With cmd
..CommandText = pSQL
..CommandType = 1
set .ActiveConnection = 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.QueryString("Action") = 1 then
username = Trim(request.form("username"))
password = Trim(request.form("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
%>

Jun 15 '06 #1
Share this Question
Share on Google+
8 Replies


P: n/a
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:
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.CreateObject("ADODB.Connection")
conn.open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" &
Server.MapPath("/db/upload/stelladb.mdb") & ";"
Set cmd = Server.CreateObject("adodb.command")
With cmd
.CommandText = pSQL
.CommandType = 1
set .ActiveConnection = 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.QueryString("Action") = 1 then
username = Trim(request.form("username"))
password = Trim(request.form("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
%>


Jun 15 '06 #2

P: n/a
I did this:

<%
Sub RunQueryString (pSQL,parms)
Set rs = Server.CreateObject("ADODB.Recordset")
..Execute rs,parms,128
End Sub
%>

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

the results was HTTP:500 Internal server error.

solomon_13000 wrote:
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.CreateObject("ADODB.Connection")
conn.open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" &
Server.MapPath("/db/upload/stelladb.mdb") & ";"
Set cmd = Server.CreateObject("adodb.command")
With cmd
.CommandText = pSQL
.CommandType = 1
set .ActiveConnection = 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.QueryString("Action") = 1 then
username = Trim(request.form("username"))
password = Trim(request.form("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
%>


Jun 15 '06 #3

P: n/a
I have even tried the following method:

Sub RunQueryString (pSQL,parms)
Set rs = Server.CreateObject("ADODB.Recordset")
Dim p
set rs = .Execute(p,parms,128)
End Sub

and I am getting the following error:

Type: Nothing

Microsoft VBScript runtime error '800a01a8'

Object required
solomon_13000 wrote:
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.CreateObject("ADODB.Connection")
conn.open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" &
Server.MapPath("/db/upload/stelladb.mdb") & ";"
Set cmd = Server.CreateObject("adodb.command")
With cmd
.CommandText = pSQL
.CommandType = 1
set .ActiveConnection = 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.QueryString("Action") = 1 then
username = Trim(request.form("username"))
password = Trim(request.form("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
%>


Jun 15 '06 #4

P: n/a

solomon_13000 wrote:
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.CreateObject("ADODB.Connection")
conn.open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" &
Server.MapPath("/db/upload/stelladb.mdb") & ";"
Set cmd = Server.CreateObject("adodb.command")
With cmd
.CommandText = pSQL
.CommandType = 1
set .ActiveConnection = 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.QueryString("Action") = 1 then
username = Trim(request.form("username"))
password = Trim(request.form("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
%>


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

Jun 15 '06 #5

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

sql = "SELECT Count(*) FROM Account WHERE username=? AND password=?"
solomon_13000 wrote:
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.CreateObject("ADODB.Connection")
conn.open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" &
Server.MapPath("/db/upload/stelladb.mdb") & ";"
Set cmd = Server.CreateObject("adodb.command")
With cmd
.CommandText = pSQL
.CommandType = 1
set .ActiveConnection = 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.QueryString("Action") = 1 then
username = Trim(request.form("username"))
password = Trim(request.form("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
%>


Jun 15 '06 #6

P: n/a
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.CreateObject("ADODB.Connection")
Set rs = Server.CreateObject("ADODB.Recordset")
conn.open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" &
Server.MapPath("/db/upload/stelladb.mdb") & ";"
Set cmd = Server.CreateObject("adodb.command")
With cmd
.CommandText = pSQL
.CommandType = 1
set .ActiveConnection = 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.QueryString("Action") = 1 then
username = Trim(request.form("username"))
password = Trim(request.form("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:
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.CreateObject("ADODB.Connection")
conn.open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" &
Server.MapPath("/db/upload/stelladb.mdb") & ";"
Set cmd = Server.CreateObject("adodb.command")
With cmd
.CommandText = pSQL
.CommandType = 1
set .ActiveConnection = 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.QueryString("Action") = 1 then
username = Trim(request.form("username"))
password = Trim(request.form("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
%>


Jun 15 '06 #7

P: n/a
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 adExecuteNoRecords.

The clue may be in that!

Martin

"solomon_13000" <so***********@yahoo.com> wrote in message
news:11**********************@y41g2000cwy.googlegr oups.com...
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.CreateObject("ADODB.Connection")
Set rs = Server.CreateObject("ADODB.Recordset")
conn.open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" &
Server.MapPath("/db/upload/stelladb.mdb") & ";"
Set cmd = Server.CreateObject("adodb.command")
With cmd
.CommandText = pSQL
.CommandType = 1
set .ActiveConnection = 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.QueryString("Action") = 1 then
username = Trim(request.form("username"))
password = Trim(request.form("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:
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.CreateObject("ADODB.Connection")
conn.open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" &
Server.MapPath("/db/upload/stelladb.mdb") & ";"
Set cmd = Server.CreateObject("adodb.command")
With cmd
.CommandText = pSQL
.CommandType = 1
set .ActiveConnection = 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.QueryString("Action") = 1 then
username = Trim(request.form("username"))
password = Trim(request.form("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
%>

Jun 16 '06 #8

P: n/a
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(banana,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_13000" <so***********@yahoo.com> wrote in message
news:11**********************@y41g2000cwy.googlegr oups.com...
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.CreateObject("ADODB.Connection")
Set rs = Server.CreateObject("ADODB.Recordset")
conn.open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" &
Server.MapPath("/db/upload/stelladb.mdb") & ";"
Set cmd = Server.CreateObject("adodb.command")
With cmd
.CommandText = pSQL
.CommandType = 1
set .ActiveConnection = 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.QueryString("Action") = 1 then
username = Trim(request.form("username"))
password = Trim(request.form("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:
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.CreateObject("ADODB.Connection")
conn.open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" &
Server.MapPath("/db/upload/stelladb.mdb") & ";"
Set cmd = Server.CreateObject("adodb.command")
With cmd
.CommandText = pSQL
.CommandType = 1
set .ActiveConnection = 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.QueryString("Action") = 1 then
username = Trim(request.form("username"))
password = Trim(request.form("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
%>

Jun 16 '06 #9

This discussion thread is closed

Replies have been disabled for this discussion.