Re: Update Database from DataAdapter

From: William \(Bill\) Vaughn (billvaRemoveThis_at_nwlink.com)
Date: 09/24/04


Date: Fri, 24 Sep 2004 09:52:56 -0700

This code does not populate the DataAdapter with action queries
(UpdateCommand etc.). Executing Update will return the exception you're
seeing. You need to build these commands manually or use the CommandBuilder
to get ADO to build them.

-- 
____________________________________
William (Bill) Vaughn
Author, Mentor, Consultant
Microsoft MVP
www.betav.com
Please reply only to the newsgroup so that others can benefit.
This posting is provided "AS IS" with no warranties, and confers no rights.
__________________________________
"Strider" <Strider@discussions.microsoft.com> wrote in message 
news:356D163D-992C-419B-ACF1-703A01890D70@microsoft.com...
> Here is my code of what im trying to do. What should i change to this
>
>   Public Shared Function UpdateTable(ByVal ds As DataSet, ByVal dbloc As
> String, ByVal tableName As String)
>        Try
>            'Create a connection to the new database.
>            Dim ssceconn As New SqlCeConnection("Data Source = " & dbloc)
>            Dim sqlDA As SqlCeDataAdapter
>
>            'Select everything from the Routes table.
>            sqlDA = New SqlCeDataAdapter("SELECT * FROM " & tableName,
> ssceconn)
>
>            sqlDA.Update(ds, tableName)
>        Catch err As SqlCeException
>            MsgBox(err.Message)
>        End Try
>    End Function
>
> "Val Mazur" wrote:
>
>> Hi,
>>
>> Calling Update should do this, but in a case of your DataSet was 
>> populated
>> using Dataadapter (DA). In a case if your dataSet fall fabricated, then 
>> DA
>> will not know anything about underlying database. Another potential issue 
>> is
>> the you call AcceptChanges before calling Update method of DA. In this 
>> case
>> AcceptChanges will reset state of the rows to unmodified and DA will not 
>> see
>> any changes in a DataSet.
>>
>> -- 
>> Val Mazur
>> Microsoft MVP
>>
>>
>> "Strider" <Strider@discussions.microsoft.com> wrote in message
>> news:C934CEFE-DC65-43DA-B1B5-4B6E242E4715@microsoft.com...
>> > Hey,
>> > here is my problem. I have a dataSet which contains data that i want to
>> > add
>> > to my database. But i dont know how to update the dataadapter with the
>> > dataset.
>> > i've tried da.update(ds,tableName) but it does not update it.
>> >
>> > can anyone help
>> >
>> > Cheers
>>
>>
>> 


Relevant Pages

  • Re: How to debug DataGridTableStyle?
    ... DataSets that are populated from a DataAdapter tend to be no different ... populate something by hand, you might miss what a DataAdapter might normally ... > This has to be something specific to my custom grid. ... I can display 1 of 2 columns. ...
    (microsoft.public.dotnet.languages.csharp)
  • RE: view vs sproc
    ... "Shai Goldberg" wrote: ... you can use the Fill of a DataAdapter to directly fill a DataTable ... >> i have a query containing inner joins....i use it to populate my truegrid. ...
    (microsoft.public.dotnet.framework.adonet)
  • RE: view vs sproc
    ... you can use the Fill of a DataAdapter to directly fill a DataTable ... > i have a query containing inner joins....i use it to populate my truegrid. ...
    (microsoft.public.dotnet.framework.adonet)
  • Re: Reading data in to a DataSet
    ... have to do is build and populate a datatable as you iterate through the ... Do this for each column in the datareader, so if 6 fields were in your ... then just populate them, ... or can it only be done with a DataAdapter? ...
    (microsoft.public.dotnet.framework.adonet)
  • Re: Update Database from DataAdapter
    ... Calling Update should do this, but in a case of your DataSet was populated ... will not know anything about underlying database. ... AcceptChanges will reset state of the rows to unmodified and DA will not see ... But i dont know how to update the dataadapter with the ...
    (microsoft.public.data.ado)