Click to See Complete Forum and Search --> : Visual Basic .NET question about updating database...


Paladyr
03-07-2004, 06:11 PM
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

ksuohio
03-10-2004, 03:08 PM
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.

GPig
03-12-2004, 02:07 PM
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?