|
Prev: Only English is Allowed
Next: Connection string issue??
From: solomon_13000 on 15 Jun 2006 05:36 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 %>
From: solomon_13000 on 15 Jun 2006 05:42 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 > %>
From: solomon_13000 on 15 Jun 2006 06:21 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 > %>
From: solomon_13000 on 15 Jun 2006 07:37 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 > %>
From: Mike Brind on 15 Jun 2006 08:37
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 |