Well Hello daniweb,
I want to point out that I am barely beginning to learn VB.net for my A-Level Computing Course.
So, I was asked to make a Currency Conversion Program and make it have a Transaction Log that is automatically updated when the user makes a conversion. I chose not to use buttons when converting, making use of the TextBox.TextChanged and ComboBox.SelectedIndexChanged.
I have an Access Database with a table called "tbl_Transaction" for my transaction log and I use the System.Data.OleDb. Here is the part of the code responsible for updating the "tbl_Transaction" table.
Dim da As OleDb.OleDbDataAdapter
Dim dSet As New DataSet
Dim sqlStat As String = "SELECT * FROM tbl_Transaction"
Dim cb As New OleDb.OleDbCommandBuilder(da)
Dim dsNewRow As DataRow
...
Private Sub SaveToLog()
Try
da = New OleDb.OleDbDataAdapter(sqlStat, cnn)
da.Fill(dSet, "TransactionLog")
dsNewRow = dSet.Tables("TransactionLog").NewRow()
dsNewRow.Item(1) = ComboBoxFrom.Text
dsNewRow.Item(2) = ComboBoxTo.Text
dsNewRow.Item(3) = CurrencyFrom.Text
dsNewRow.Item(4) = CurrencyTo.Text
dSet.Tables("TransactionLog").Rows.Add(dsNewRow)
dSet.Tables("TransactionLog").AcceptChanges()
dSet.AcceptChanges()
da.Update(dSet, "TransactionLog")
MsgBox("Transaction Logged to DB")
Catch ex As Exception
MsgBox("Error writing to Transaction Log!")
End Try
End Sub
Even if I get the message "Transaction Logged to DB", the table stays unchanged, can you guys help me?