• 15 years ago

    Hi All,

    Im having some problems with copying data from my dataset back to my access database. All im trying to do is get the contents of TextBox1 into the finalSolution field. I can't understand it im getting no errors and no updated data, even though im using the update method?

    Also how is Console.WriteLine meant to work should a dos screen pop up or ?

    Heres the code

    Private Sub Progress_Activated(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Activated

    Dim db As OleDbConnection = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\helpdesk.mdb;")
    Dim faultsDA As OleDbDataAdapter = New OleDbDataAdapter("SELECT * FROM faults", db)

    faultsDA.UpdateCommand = New OleDbCommand("SELECT * FROM faults ")
    Dim faultsDS As DataSet = New DataSet()

    faultsDA.Fill(faultsDS, "faults")

    Dim faultsRow As System.Data.DataRow
    For Each faultsRow In faultsDS.Tables("faults").Rows
    Console.WriteLine("Company Name: " & faultsRow("userName"))
    faultsRow("finalSolution") = TextBox1.Text
    Next faultsRow

    faultsDA.Update(faultsDS, "faults")
    MsgBox("finito !")

    Thanks In Advance!!

  • 15 years ago

    Your DataAdapter is configured incorrectly. The UpdateCommand should be a Sql statement or stored procedure that updates the database but you have a select command. There are command properties of the DataAdapter:-


    You should set the update command to a sql statement that updates the database "update table set fieldname=" etc.

Post a reply

Enter your message below

Sign in or Join us (it's free).


Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“Owning a computer without programming is like having a kitchen and using only the microwave oven” - Charles Petzold