Visual Basic .NET question about updating database...

Sharky Forums


Results 1 to 3 of 3

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

  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

  2. #2
    . ksuohio's Avatar
    Join Date
    Oct 2001
    Location
    Atlanta, GA
    Posts
    2,721
    I thought that since ADO.Net was disconnected unlike ADO, you could not update in the same manor. Rather you had to run a command that was a regular update statement.
    ---------------------------------------------------------------
    - Asus M50 Laptop - C2D T9300 - 4 gig RAM - Radeon HD 3650 - Vista x64 Ultimate

    - Intel i7-3770K - Asus P8Z77-V DELUXE - 32gig RAM - Radeon HD7970 Ghz - Plextor M3 256GB/120GB OCZ Vertex3
    - LG BluRay - Razor Blackwidow Ultimate Keyboard - Logitech G9x
    - HP ZR2740w/Asus LCD - W7 Ultimate

    ---------------------------------------------------------------

  3. #3
    Catfish
    Join Date
    Jun 2002
    Posts
    103
    sqlselectcommand1.commandtext= "select blah blah"
    sqldataAdapter1.fill(datasetofrighttype1)

    'use index to change values in dataset like:
    datasetofrighttype1.tablename(0).nameofcolumninDB = dfg.text.trim

    'send the dataAdapter the change dataset,and it will update database
    sqldataAdapter1.update(datasetofrighttype1)

    'you can also send the previous commands a datatable or array of 'datarows



    is this the point you want to get to?

Posting Permissions

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