Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27418

VS 2010 How to Update the access table rows with relative rows from another table

$
0
0
Dear All,
I am creating a simple banking application for my college project in VB.net 2010 with access 2003 as back end.
I have created four tables as CashDepositReg, CashDepositTran, CashWidrawReg, CashWidrawTran which is nothing its like register tables and its transactions tables.
If user deposit money it will save in CashDepositReg and its transaction details will save in CashDepositTran
If user withdraw his deposited money those info will save in CashWidrawReg and CashWidrawTran.
now my problem is, if user delete his cash withdraw in CashWidrawReg the withdraw amt should update in CashDepositTran.WidrawAmt against each respective transactions

Table: CashDepositReg
CRegID | CashDepDate | UserID | DepAmt
1 | 09/Mar/2013 | 123 | 10500

Table: CashDepositTran
CTranID | CRegID | CashDepDate | UserID | DepAmt | WidrawAmt
1 | 1 | 09/Mar/2013 | 123 | 10000 | 10000
2 | 1 | 09/Mar/2013 | 123 | 500 | 500

Table: CashWidrawReg
WRegID | CashWidDate | UserID | WidrawAmt
15 | 10/Mar/2013 | 123 | 10500

Table: CashWidrawTran
WTranID | WRegID | CTransID | CashWidDate | UserID | WidrawAmt
17 | 15 | 1 | 10/Mar/2013 | 123 | 10000
18 | 15 | 2 | 10/Mar/2013 | 123 | 500

I use the following query to get the CashWidrawTran details and now i need to pass this output to the update query to update the CashDepositTran.WidrawAmt as 0 because user cancel the particular cash withdraw details in CashWidrawReg

Code:

Dim conn123 As New OleDbConnection("My connection string")

Dim Query As String = "SELECT (B.WidrawAmt) AS test FROM CashWidrawReg A INNER JOIN CashWidrawTran B on A.WRegID = B.WRegID WHERE A.WRegID = 15"

Dim Cmd As New OleDbCommand(Query, conn123)

Dim Dr As OleDbDataReader
Dim outPutString As String = ""

conn123.Open()

Dr = Cmd.ExecuteReader
With Dr
If .HasRows = True Then
While .Read
outPutString += .Item(0).ToString & ","
End While
End If
End With
Dr.Close()

Output
10000,500,


Viewing all articles
Browse latest Browse all 27418

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>