I have found that a separate DataAdapter for each table is necessary and
calling them in the right order is crucial in many instances.  It
matters how your schema in the database (not the DataSet) is expecting
the data as to how you would call the updates.  Are you using one or
three data adapters?  If you are using SQL Server (2k?), maybe diffgrams
are the better way to go if you can use SQLXML 3.0.

Have I muddied the waters or clarified them?

Thanks,

Shawn Wildermuth
[EMAIL PROTECTED]

> -----Original Message-----
> From: dotnet discussion [mailto:[EMAIL PROTECTED]]
> On Behalf Of Chris Anderson
> Sent: Thursday, May 16, 2002 5:57 AM
> To: [EMAIL PROTECTED]
> Subject: [DOTNET] ADO.NET multiple table updates
>
>
> I have a dataset consisting of 3 datatables
>
> There is one parent table, and 2 child tables
>
> I have set up foreign key constraints (with UpdateRule =
> Rule.Cascade) on the primary key, etc
>
> The user populates the parent table with a new record, then
> populates the child tables, and finally hits update
>
> At this point, I want to save the dataset to the database (SQL Server)
>
> I've create the SPs, etc, and they work fine, but I'm having
> problems updating the child tables
>
> I use a SQLDataAdapter to update the parent table, and the PK
> field is updated from the database This in turn updates the
> appropriate field in the child datatables via the foreignKeyContraints
>
> The problem, is that at this point, the child tables seem to
> be updated (ie GetChanges returns Nothing, and no update gets
> done when I pass it to it's
> DataAdapter)
> GetChanges *does* however return the changes before calling
> update on the parent table, so I'm thinking that it's
> expecting me to update all three tables in one shot.
>
> I'd supply code, but the above pretty well sums up the
> situation (and the code is a little long winded)
>
> I've been on this for a few hours now, and the help samples either
>         update the parent table
>         add the records to the child DataTable
>         then update the child table
>
> or
>         the entire dataset is passed to the InsertCommand of
> the parent table via GetXML
>
> I can't do the former, as the dataset is being populated
> first and I can't do the latter as the dataset *could* be
> quite large (resulting in indeterminately sized (and
> potentially large) XML strings being passed to the SP)
>
> Hoping someone can help :-)
> Merak
>
> You can read messages from the DOTNET archive, unsubscribe
> from DOTNET, or subscribe to other DevelopMentor lists at
> http://discuss.develop.com.
>

You can read messages from the DOTNET archive, unsubscribe from DOTNET, or
subscribe to other DevelopMentor lists at http://discuss.develop.com.

Reply via email to