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%>

 
i tried response.write(userName) cause in varible i have N cap

 
I'm assuming there is only one record for the user, if so this section -

<%WHILE NOT RS.EOF%>

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

<%RS.MoveNext
WEND
myCon.Close%>

becomes just

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



 


no there about 6-7 records in my_table
 
still the same error mess,
 
Try it like this

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

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

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

Response.Write RS(&quot;cl_balance &quot;)
Rs.Close
myCon.Close%>



 
still the same problem
 
try this

<%
userName =Request(&quot;name&quot;)
' test the form value passed
Response.Write userName

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,adOpenKeyset, adLockOptimistic

If NOT RS.EOF Then

balance = RS(&quot;cl_balance&quot;)
' test values
Response.Write balance

withdraw = request(&quot;amount&quot;)
' test values
Response.Write withdraw

balance = cLng(balance) - cLng(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
Else
Response.Write &quot;Record not found!&quot;
End If

RS.Update

Rs.Close
myCon.Close
Set myCon = Nothing
%>


_________________________________________________________
[sub]$str = &quot;sleep is good for you. sleep gives you the energy you need to function&quot;;
$Nstr = ereg_replace(&quot;sleep&quot;,&quot;coffee&quot;,$str); echo $Nstr;[/sub]
onpnt2.gif
[sup] [/sub]
 
Just my editor's eye but raj8 states that he's written:

WHERE cl_name =' &quot;&userName &&quot; '&quot;,myCon,1,3

while everyone is telling him to write:

WHERE cl_name ='&quot;&userName &&quot;'&quot;,myCon,1,3

That leading and trailing space in the Where is probably killing his search.

I know I never make edits to things that I'm sure are right.

raj8, please check that line.

-Rob
 
hi everyone thanks for help, my prog is working. I has spaces in front of records in the database, which i was trying to get, cause i had (' &quot;&clName& &quot; ')spaces between the colons & speech marks instead of ('&quot;&clName& &quot;')in my INSERT method.

thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top