Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

updating existing recordset

Status
Not open for further replies.

raj8

IS-IT--Management
May 21, 2003
19
0
0
GB
hi I get this error message in withdraw_money.asp, plz someone help
thanks in advance

here are the error details

Error Type:
Microsoft VBScript runtime (0x800A01B6)
Object doesn't support this property or method: 'Update'
withdraw_money.asp, line 30


here is my code:
==================

<%
userName =Request(&quot;name&quot;)

dim sql
Set myCon = Server.CreateObject(&quot;ADODB.Connection&quot;)
okay = &quot;driver={Microsoft Access Driver (*.mdb)}; &quot; &_
&quot;DBQ=&quot; & Server.Mappath(&quot;client_details.mdb&quot;) & &quot;;&quot;
myCon.Open okay
Set RS = Server.CreateObject(&quot;ADODB.RecordSet&quot;)
'RS.ActiveConnection = myCon

sql=&quot;SELECT cl_balance FROM my_table WHERE cl_name =' &quot;&userName &&quot; ' ;&quot;

RS.Open sql , myCon, adLockOptimistic
balance = RS(&quot;cl_balance&quot;)
withdraw = request(&quot;amount&quot;)
balance = balance - withdraw
if balance > withdraw then
RS(&quot;cl_balance&quot;)=balance
Response.Write(&quot;transaction successful&quot;)
else
Response.Write(&quot;transaction unsuccessful&quot;)
end if

RS.Update
============== line 30
RS.MoveNext
RS.Close
%>

<%WHILE NOT RS.EOF%>

<%Response.Write(RS(&quot;cl_balance&quot;))%>
<%RS.MoveNext
WEND
myCon.Close%>

 
Try writing your connection string like this

set myCon =Server.CreateObject(&quot;ADODB.Connection&quot;)
myCon.open &quot;Provider=Microsoft.Jet.OLEDB.4.0;Data Source=&quot; & server.mappath(&quot;client_details.mdb&quot;)

Set RS = Server.CreateObject(&quot;ADODB.RecordSet&quot;)

rs.open &quot;SELECT * FROM agents WHERE name ='Philip Troy'&quot;,myCon,1,3


Also this won't work

<%WHILE NOT RS.EOF%>
<%Response.Write(RS(&quot;cl_balance&quot;))%>
<%RS.MoveNext
WEND
myCon.Close%>

because you close your recordset just before it. Replace the RS.Close with Rs.MoveFirst



 

hi i get this message when i made changes
Error Type:
ADODB.Recordset (0x800A0E79)
Operation is not allowed when the object is open.
/cw1/withdraw_money.asp, line 22

line 22 is:
RS.Open sql , myCon, adLockOptimistic
 
if i type in

RS.Open sql ,myCon,adOpenStatic,adLockOptimistic, adCmdTable

i still get same error
 
do u have any suggestions about this? thanks 4 ur help
 
Well you're obviously not following my example.

set myCon =Server.CreateObject(&quot;ADODB.Connection&quot;)
myCon.open &quot;Provider=Microsoft.Jet.OLEDB.4.0;Data Source=&quot; & server.mappath(&quot;client_details.mdb&quot;)

Set RS = Server.CreateObject(&quot;ADODB.RecordSet&quot;)

rs.open =&quot;SELECT cl_balance FROM my_table WHERE cl_name =' &quot;&userName &&quot;'&quot;,myCon,1,3



 
hi i get this error mess this time

Microsoft VBScript compilation (0x800A0401)
Expected end of statement
/cw1/withdraw_money2222.asp, line 16, column 75
rs.open =&quot;SELECT cl_balance FROM my_table WHERE cl_name =' &quot;&userName &&quot;'&quot;,myCon,1,3
--------------------------------------------------------------------------^
 
I am sorry new error mess

Microsoft VBScript compilation (0x800A0409)
Unterminated string constant
/cw1/withdraw_money2222.asp, line 16, column 84
rs.open &quot;SELECT cl_balance FROM my_table WHERE cl_name =' &quot;&userName &&quot; ',myCon,1,3
-----------------------------------------------------------------------------------^
 
next error

Error Type:
ADODB.Recordset (0x800A0E79)
Operation is not allowed when the object is open.
/cw1/withdraw_money2222.asp, line 18


RS.Open ,myCon,adOpenStatic,adLockOptimistic, adCmdTable
 
i posted my code again if u like 2 look at it again
thanks
 
<%
userName =Request(&quot;name&quot;)


dim sql
set myCon =Server.CreateObject(&quot;ADODB.Connection&quot;)
myCon.open &quot;Provider=Microsoft.Jet.OLEDB.4.0;Data Source=&quot; & server.mappath(&quot;client_details.mdb&quot;)
Set RS = Server.CreateObject(&quot;ADODB.RecordSet&quot;)

'RS.ActiveConnection = myCon
RS.open &quot;SELECT cl_balance FROM my_table WHERE cl_name =' &quot;&userName &&quot; '&quot;,myCon,1,3
RS.Open ,myCon,adOpenStatic,adLockOptimistic, adCmdTable

balance = RS(&quot;cl_balance&quot;)
withdraw = request(&quot;amount&quot;)
balance = balance - withdraw
if balance > withdraw then
RS(&quot;cl_balance&quot;)=balance
Response.Write(&quot;transaction successful&quot;)
else
Response.Write(&quot;transaction unsuccessful&quot;)
end if

RS.Update
RS.MoveFirst

%>

<%WHILE NOT RS.EOF%>

<%Response.Write(RS(&quot;cl_balance&quot;))%>

<%RS.MoveNext
WEND
myCon.Close%>
 
Remove this line -

RS.Open ,myCon,adOpenStatic,adLockOptimistic, adCmdTable

And amend this line, should be no spaces after or before the apostrophe -

RS.open &quot;SELECT cl_balance FROM my_table WHERE cl_name ='&quot;&userName &&quot;'&quot;,myCon,1,3




 
ADODB.Field (0x800A0BCD)
Either BOF or EOF is True, or the current record has been deleted. Requested operation requires a current record.
/cw1/withdraw_money2222.asp, line 18


line 18 is
balance = RS(&quot;cl_balance&quot;)
 
i have records in the database & i tried what u told me but dint work


Error Type:
ADODB.Field (0x800A0BCD)
Either BOF or EOF is True, or the current record has been deleted. Requested operation requires a current record.
/cw1/withdraw_money2222.asp, line 18


Browser Type:
Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)

Page:
POST 19 bytes to /cw1/withdraw_money2222.asp

POST Data:
name=rups&amount=22
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top