Results 1 to 4 of 4

Thread: Insert Command and Update database

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Jun 2002
    Posts
    17

    Question Insert Command and Update database

    The following sub is used to store in the dataset a new record/row.

    With dssupport.Tables("Supportcall")
    NewRow = .NewRow()
    NewRow("ID") = Me.txtcallnumber.Text
    NewRow("Description")=Me.txtcalldescription.Text
    .Rows.Add(NewRow)
    End With

    However when I come to hit the update the database with

    dbsupport.Update(dssupport, "Supportcall")

    I am bombed out with a insertcommand error.

    How and where do I configure this?

  2. #2
    Addicted Member wolfofthenorth's Avatar
    Join Date
    Jan 2001
    Location
    Tatooine
    Posts
    169
    You might be able to configure it in the DataAdapter Configuration Wizard.

    You could also declare command objects in code, and have them update the database.

    Did you use the IDE controls and drag them on the form, or did you declare all the objects in code?
    That which does not kill us, only makes us stronger.

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Jun 2002
    Posts
    17

    Cool

    I declared them in code

    Dim dbsupport As New OleDbDataAdapter()
    Dim dssupport As New DataSet()
    Dim saved As Boolean
    Dim dbconn As OleDbConnection = New OleDbConnection("Provider=Microsoft.jet.oledb.4.0;" & "Data Source =P:\Support Calls\mosaic.mdb")
    Dim cmdsupport As New OleDbCommand()

    with

    cmdsupport = dbconn.CreateCommand
    cmdsupport.CommandText = "select * from Supportcall"
    dbsupport.SelectCommand = cmdsupport

    dbsupport.Fill(dssupport, "SupportCall")

    declared in the form load

  4. #4
    old fart Frans C's Avatar
    Join Date
    Oct 1999
    Location
    the Netherlands
    Posts
    2,926
    It looks like you didn't create an insert command at all. In order to insert a record, the dataadapter needs an insert command (and for updates and deletes an update and a delete command as well).

    Have a look at this tutorial: Using ADO.NET

Posting Permissions

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



Click Here to Expand Forum to Full Width