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?

You might have to set your command for the update:

da.UpdateCommand = New OleDBCommandBuilder(da).GetUpdateCommand()

Then issue the update.

See if this helps.

Thank you, but this does not solve my problem sadly :(

A transaction log does not necessarily imply a database. It could be as simple as one or more files of the form name.log which could be simple text files. That's what I used for several dozen applications in my corporate environment. If the name is of the form yyyy-mm-dd.log or yyyy-mm.log then you can keep the log files from growing indefinitely. All you would have to do is open the file for append (create if not present). That simplifies the complexity and the code considerably. It also means you don't need a special program to view the logs. It also makes it easier to search with something like GREP.

commented: Might help if I read the question a little better next time, huh? +9

@beginnerdev - You did read the question. Not your fault if the OP decided on the overkill option.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.