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
%> 8 2123
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 %>
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 %>
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 %>
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
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 %>
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 %>
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 %>
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 %> This discussion thread is closed Replies have been disabled for this discussion. Similar topics
5 posts
views
Thread by Neal Coombes |
last post: by
|
16 posts
views
Thread by G Patel |
last post: by
|
15 posts
views
Thread by Nerox |
last post: by
|
12 posts
views
Thread by Jose Fernandez |
last post: by
|
3 posts
views
Thread by tshad |
last post: by
|
12 posts
views
Thread by Michael Maes |
last post: by
|
20 posts
views
Thread by lovecreatesbeauty |
last post: by
|
6 posts
views
Thread by Tim Roberts |
last post: by
|
7 posts
views
Thread by Terry Olsen |
last post: by
| | | | | | | | | | | |