|
 |
asp_databases thread: double query problem
Message #1 by "peter" <ph@t...> on Mon, 12 Jun 2000 19:51:28
|
|
The following code throws up the following error message.
[Microsoft][ODBC Microsoft Access Driver] Too few parameters. Expected 1.
/ps/bww/status1.asp, line 34
Anyone know what I need to do to get this to work? Many thanks
cheers
peter
<% ID = Request.Cookies("ID")%>
<%
curDir = Server.MapPath("\bww\ps.mdb")
Set oConn = Server.CreateObject("ADODB.Connection")
oConn.Open "DBQ="& curDir &";Driver={Microsoft Access Driver
(*.mdb)};DriverId=25;FIL=MS Access;"
Set oRs = Server.CreateObject("ADODB.Recordset")
Set oRs.ActiveConnection = oConn
oRs.Source = " SELECT * FROM Customers WHERE CustomerID=" &ID
oRs.Open
If oRs.EOF = TRUE Then
Response.Redirect("error.htm")
else
strSessions =oRs("sessions").Value
If strSessions < 1 Then
Response.Redirect("pay.asp")
else
strSQL = "UPDATE Customers "
strSQL = strSQL & "SET sessions = sessions - 1 " 'Can i do this
calculation inline or would it be better to use SET '"&strSessions&"'?
strSQL = strSQL & "WHERE custid ='"& ID &"' "
oConn.execute(strSQL) 'line34
....
oRs.close
%>
Message #2 by AlanHughesy@a... on Tue, 13 Jun 2000 05:33:54 EDT
|
|
I had this problem before and although it didn't seem like a likely solution
it was just a syntax error in the sql I had used. I removed or added a comma
and that solved the problem.
Hope this is some help.
Alan
Message #3 by "Ken Schaefer" <ken.s@a...> on Tue, 13 Jun 2000 20:29:29 +1000
|
|
Peter,
Comment out the oConn.execute(strSQL) line and instead do this:
Response.Write(strSQL)
Post the output to the list.
Cheers
Ken
----- Original Message -----
From: "peter"
To: "ASP Databases" <asp_databases@p...>
Sent: Monday, June 12, 2000 7:51 PM
Subject: [asp_databases] double query problem
> The following code throws up the following error message.
>
> [Microsoft][ODBC Microsoft Access Driver] Too few parameters. Expected 1.
> /ps/bww/status1.asp, line 34
>
> Anyone know what I need to do to get this to work? Many thanks
>
> cheers
>
> peter
>
> <% ID = Request.Cookies("ID")%>
> <%
> curDir = Server.MapPath("\bww\ps.mdb")
> Set oConn = Server.CreateObject("ADODB.Connection")
> oConn.Open "DBQ="& curDir &";Driver={Microsoft Access Driver
> (*.mdb)};DriverId=25;FIL=MS Access;"
>
> Set oRs = Server.CreateObject("ADODB.Recordset")
> Set oRs.ActiveConnection = oConn
>
> oRs.Source = " SELECT * FROM Customers WHERE CustomerID=" &ID
> oRs.Open
>
> If oRs.EOF = TRUE Then
> Response.Redirect("error.htm")
> else
> strSessions =oRs("sessions").Value
> If strSessions < 1 Then
> Response.Redirect("pay.asp")
> else
>
> strSQL = "UPDATE Customers "
> strSQL = strSQL & "SET sessions = sessions - 1 " 'Can i do this
> calculation inline or would it be better to use SET '"&strSessions&"'?
>
> strSQL = strSQL & "WHERE custid ='"& ID &"' "
>
> oConn.execute(strSQL) 'line34
> ....
>
> oRs.close
> %>
>
|
|
 |