J
JH
I have the following simple code. I can see the changes in the dataset by
displaying it to a data grid. All the new rows added
can be seen on the data grid. But when I try to update the database, it does
not commit. What am I doing wrong?? I tried both
codes at the end of this message.
Any help appreciated
dim ConnectionString2 As String =
"Provider=Microsoft.Jet.OLEDB.4.0;Password='';" & _
"User ID=Admin;Data Source= C:\temp\account.mdb;" & _
"Jet OLEDBatabase Password='password';"
Dim Connection2 As OleDbConnection = New OleDbConnection(ConnectionString2)
Dim sqlCommand2 As String = "SELECT * from acc_checking"
Dim command2 As OleDbCommand = New OleDbCommand(sqlCommand2)
command2.CommandType = CommandType.Text
Connection2.Open()
command2.Connection = Connection2
Dim oleDBDataadapter2 As OleDbDataAdapter = New OleDbDataAdapter
oleDBDataadapter2.SelectCommand = command2
Dim LogDs2 As New DataSet
oleDBDataadapter2.Fill(LogDs2, "acc_checking")
'add row to the dataset
Dim row As DataRow
row = LogDs2.Tables("Acc_Checking").NewRow()
row("PinNumber") = CDec(TPinNumber)
row("TransactDate") = Now.Date
row("Credit") = 0.0
row("Debit") = AmtMoney
row("Cbalance") = TCbalance
'update data table from the current dataset
oleDBDataadapter2.Update(LogDs2)
' oleDBDataadapter2.Update(LogDs2, "Acc_checking")
displaying it to a data grid. All the new rows added
can be seen on the data grid. But when I try to update the database, it does
not commit. What am I doing wrong?? I tried both
codes at the end of this message.
Any help appreciated
dim ConnectionString2 As String =
"Provider=Microsoft.Jet.OLEDB.4.0;Password='';" & _
"User ID=Admin;Data Source= C:\temp\account.mdb;" & _
"Jet OLEDBatabase Password='password';"
Dim Connection2 As OleDbConnection = New OleDbConnection(ConnectionString2)
Dim sqlCommand2 As String = "SELECT * from acc_checking"
Dim command2 As OleDbCommand = New OleDbCommand(sqlCommand2)
command2.CommandType = CommandType.Text
Connection2.Open()
command2.Connection = Connection2
Dim oleDBDataadapter2 As OleDbDataAdapter = New OleDbDataAdapter
oleDBDataadapter2.SelectCommand = command2
Dim LogDs2 As New DataSet
oleDBDataadapter2.Fill(LogDs2, "acc_checking")
'add row to the dataset
Dim row As DataRow
row = LogDs2.Tables("Acc_Checking").NewRow()
row("PinNumber") = CDec(TPinNumber)
row("TransactDate") = Now.Date
row("Credit") = 0.0
row("Debit") = AmtMoney
row("Cbalance") = TCbalance
'update data table from the current dataset
oleDBDataadapter2.Update(LogDs2)
' oleDBDataadapter2.Update(LogDs2, "Acc_checking")