Update data in DataBase, problem with Update command
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Thread: Update data in DataBase, problem with Update command

  1. #1
    Join Date
    Aug 2012
    Posts
    1

    Update data in DataBase, problem with Update command

    Hi!
    I'm following the manual and try to update a record in a access data table, but there is some fail. I use VB Express 2010
    here is the code

    Dim my_connstr As String
    my_connstr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=""C:\Users\htrendaf\Documents\01_Skretting work\Prosjekter 2011\proj - VB stopploggextractor\DB\skr_pn_V05.mdb"""

    Dim conn As OleDb.OleDbConnection
    Dim comm As OleDb.OleDbCommand
    Dim ad As New OleDb.OleDbDataAdapter
    Dim ds As New DataSet 'System.Data.DataSet
    Dim msql As String

    conn = New OleDb.OleDbConnection(my_connstr)
    Try
    conn.Open()
    msql = "select * from es_stopplogg"
    comm = New OleDb.OleDbCommand(msql, conn)
    ad.SelectCommand = comm


    ad.Fill(ds, "Update")

    Dim cb As New OleDb.OleDbCommandBuilder(ad)

    ds.Tables("Update").Rows(1).Item(9) = "try to update"

    ad.Update(ds, "Update")


    Catch exError As System.Data.Common.DbException ' MySqlException
    MessageBox.Show(exError.ToString)
    End Try


    and then there is a fail when I execute - see the image for the fail message
    The message is in Norwegian but it stands: There is not declared a value for one or more of the needed parameters.

    What is my fail ???


    Name:  update fail.jpg
Views: 81
Size:  44.4 KB

  2. #2
    Join Date
    Sep 2012
    Posts
    6

    Re: Update data in DataBase, problem with Update command

    Dim cb As New OleDb.OleDbCommandBuilder(ad)

    ds.Tables("Update").Rows(1).Item(9) = "try to update"

    ad.Update(ds, "Update")
    check cb.getUpdateCommand, if it has right structure...

  3. #3
    Join Date
    Jul 2001
    Location
    Sunny South Africa
    Posts
    11,092

    Re: Update data in DataBase, problem with Update command

    Please also just use use CODE tags when posting code - it makes the code more legible. Look here :

    http://forums.codeguru.com/showthrea...for-more-info)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center