fpineda101
Well-known member
Hello
I'm coding this project which is supposed to be a mock ATM. The screen of the ATM is a label. I'm using the datareader and oledbcommands for the select. I am able to authenticate a user with their account no and pin.
What I want to do is update the balance of the account and insert a new row into a transaction table which stores the info from the transaction. Under ADO.NET and oledb, how would I issue an Update command and Insert command to the account and transaction tables respectively.
Below is the code I am using for the select. I tried passing a string parameter with an update command but nothing happens...
My question is, how do I pass an update command to the ExecuteSQL sub routine? Much thanks for your help!
Private Const ACCESS_CONNECT_STRING As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\VB Examples\ATM V2\bin\BANK.mdb;User Id=admin;Password=;"
dim AccessDBConnection As OleDbConnection
dim AccessDBCommand As OleDbCommand
dim AccessDBDataReader As OleDbDataReader
Public Sub ConnectDB()
AccessDBConnection = New OleDbConnection(ACCESS_CONNECT_STRING)
AccessDBConnection.Open() 'open the connection
End Sub
Public Sub OpenDataset(ByVal inSQL As String) 'for selects
ConnectDB()
AccessDBCommand = New OleDbCommand(inSQL, AccessDBConnection)
AccessDBDataReader = AccessDBCommand.ExecuteReader(CommandBehavior.CloseConnection)
End Sub
Public Sub ExecuteSQL(ByVal inSQL As String) 'for updates and inserts
AccessDBCommand = New OleDbCommand(inSQL, AccessDBConnection)
End Sub
I'm coding this project which is supposed to be a mock ATM. The screen of the ATM is a label. I'm using the datareader and oledbcommands for the select. I am able to authenticate a user with their account no and pin.
What I want to do is update the balance of the account and insert a new row into a transaction table which stores the info from the transaction. Under ADO.NET and oledb, how would I issue an Update command and Insert command to the account and transaction tables respectively.
Below is the code I am using for the select. I tried passing a string parameter with an update command but nothing happens...
My question is, how do I pass an update command to the ExecuteSQL sub routine? Much thanks for your help!
Private Const ACCESS_CONNECT_STRING As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\VB Examples\ATM V2\bin\BANK.mdb;User Id=admin;Password=;"
dim AccessDBConnection As OleDbConnection
dim AccessDBCommand As OleDbCommand
dim AccessDBDataReader As OleDbDataReader
Public Sub ConnectDB()
AccessDBConnection = New OleDbConnection(ACCESS_CONNECT_STRING)
AccessDBConnection.Open() 'open the connection
End Sub
Public Sub OpenDataset(ByVal inSQL As String) 'for selects
ConnectDB()
AccessDBCommand = New OleDbCommand(inSQL, AccessDBConnection)
AccessDBDataReader = AccessDBCommand.ExecuteReader(CommandBehavior.CloseConnection)
End Sub
Public Sub ExecuteSQL(ByVal inSQL As String) 'for updates and inserts
AccessDBCommand = New OleDbCommand(inSQL, AccessDBConnection)
End Sub