Visual Basic .NET question about updating database...

Sharky Forums


Results 1 to 3 of 3

Thread: Visual Basic .NET question about updating database...

Threaded View

  1. #1
    Mako Shark Paladyr's Avatar
    Join Date
    Mar 2001
    Location
    Cinci, OH
    Posts
    4,562

    Visual Basic .NET question about updating database...

    Okay first off I know I can use a command object to update the database but I'm looking to do something similar to this:

    Dim DataRow1 As DataRow
    Dim DataTable1 As New DataTable
    Dim da_Clients As New SqlServerCe.SqlCeDataAdapter("Select * from tblClients", cn)
    Dim myDataRowsCommandBuilder As SqlCeCommandBuilder = New SqlCeCommandBuilder(da_Clients)

    da_Clients.MissingSchemaAction = MissingSchemaAction.AddWithKey
    Dim ds_clients As New DataSet

    da_Clients.Fill(ds_clients, "tblClients")
    DataRow1 = ds_clients.Tables("tblClients").Rows.Find(strName)
    DataRow1("State#") = Trim(txtStateID.Text)
    DataRow1("SSN") = Trim(txtSSN.Text)
    DataRow1("Birthdate") = Trim(txtBirthDate.Text)
    DataRow1("Address") = Trim(txtAddress.Text)
    DataRow1("Phone") = Trim(txtPhone.Text)
    DataRow1("UCI#") = Trim(txtUCI.Text)
    DataRow1("Agency") = Trim(txtAgency.Text)
    'Tried this, still no go:
    'ds_clients.Tables("tblClients").Rows(0)("Address") = "Testing"
    da.Update(ds_clients, "tblClients")

    It throws an error on the da.Update line simply saying "Update". Seriously, that is the ENTIRE DESCRIPTION. Just "Update". Basically i'm looking for something similar to recordset updating:

    rstText.Open "query"
    rstTest("Field1") = "Blah"
    rstTest.Update

    Here's the actual error:

    An unhandled exception of type 'System.InvalidOperationException' occurred in System.Data.Common.dll

    Additional information: Update
    Last edited by Paladyr; 03-07-2004 at 07:13 PM.
    Core 2 Duo w Radeon 4850, Droid Phone, Mits HD1000U projector

Posting Permissions

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