1 Replies - 857 Views - Last Post: 13 May 2012 - 11:57 AM Rate Topic: -----

#1 Mastbaby  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 13-May 12

How to print user detail info ? and how he can make transaction !

Posted 13 May 2012 - 11:28 AM

<%
	Amount = Request.Form("txtamount")
	IDno = request.Form("optsel")
	SelectOption= request.Form("optsel")
	
	'Build connection with database
	
	set conn = server.CreateObject ("ADODB.Connection")		
	'conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & server.MapPath ("users.mdb")
	Conn.Open "DSN=Transaction"
	
	set rs = server.CreateObject ("ADODB.Recordset")		
	'Open record with entered username
	'rs.Open "SELECT ID, username , Amount FROM Table1 where ID='"& IDno &"'", conn, 1 
	
	'If there is no record with the entered id, close connection
	'and go back to balance with QueryString
	
	responce.write("thank you")
		
%>



1: its the thanks page after the user sign in successfully !

1: how can i select the person from database and display his balance in the above page in table in detail he entered except password!

2: i have tried 6 days but failed to make the transaction page ! simple if the user enter the amount and transfer it.
first it will be checked if the user have that much balance or not if yes than transfer the money to other account enter id number else show the sorry page

Is This A Good Question/Topic? 0
  • +

Replies To: How to print user detail info ? and how he can make transaction !

#2 Martyr2  Icon User is offline

  • Programming Theoretician
  • member icon

Reputation: 4354
  • View blog
  • Posts: 12,160
  • Joined: 18-April 07

Re: How to print user detail info ? and how he can make transaction !

Posted 13 May 2012 - 11:57 AM

Well you have the select there to find the user based on the IDno they submitted. So you first check if there was a record returned. Yes, ok, take out the Amount field and see if it is big enough to cover the withdraw. If so, you are going to create two updates. 1 to subtract the money from the account you found with IDno and a second to increase the amount in the account they are transferring to.

Something along these lines should help...

if !rs.EOF then
    if Amount <= rs("Amount") then
          ' Ok, they have enough, so create two updates here 
          ' Need to start a transaction
          Conn.BeginTrans

          ' Withdraw
          Conn.execute "update Table1 set Amount = Amount - " & Amount & " where ID = '" & IDno & "'"

          ' Add to other account
          Conn.execute "update Table1 set Amount = Amount + " & Amount & "where ID = '" & SomeOtherIDHere & "'"

          ' Check if any errors and if so, roll back
          if Conn.Errors.Count > 0 then
               Conn.RollbackTrans
          else
               ' All good, commit the transaction
               Conn.CommitTrans
          end if
         
    else
          ' They don't have enough, send them to sorry page
    end if
else
    ' User not found
end if



This is just to give you a general idea of how this logic works. So use it as a guideline only.

:)
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1