PC Review


Reply
Thread Tools Rate Thread

Batch updates on generated TableAdapters throws InvalidOperation

 
 
Some Bloke
Guest
Posts: n/a
 
      18th Dec 2007
Hi,

I'm trying to write a data layer for to persist regularly occuring
stats to a database using ADO.NET by collecting a few records then
updating the database in batches.

I've got a Dataset that is generated with MSDataSetGenerator that I
add rows to then pass to the Update method of the generated
TableAdapter.

When I set the batch size to anything more than 1, I get "When
batching, the command's UpdatedRowSource property value of
UpdateRowSource.FirstReturnedRecord or UpdateRowSource.Both is
invalid"

Doing a search for that exception returns no results, hence me asking
for help, but looking into it I see that UpdateRowSource.Both is the
default value but the generated InitAdapter() method of the
TableAdpater that creates the update/insert commands doesn't override
this, leading to the exception.

Strangely this did appear to be working at one point but I can not
figure out what has changed.

How can I get the code generator to set the UpdateRowSource to None?
Or is there something that I could have missed that would cause this?
Possibly a change to the database?

Thanks for any help.


 
Reply With Quote
 
 
 
 
Some Bloke
Guest
Posts: n/a
 
      6th Feb 2008
I'm still having problems with this. Right now I've added the line
this._adapter.InsertCommand.UpdatedRowSource =
System.Data.UpdateRowSource.None;
to the InitAdapter() method in the generated TableAdapter.

This means I have to be careful to replace it after making changes. I
can't think how to do this in the partial class.

Do Visual Studio's TableAdapters really offer no support for Batch
Updates???
 
Reply With Quote
 
Some Bloke
Guest
Posts: n/a
 
      6th Feb 2008
On Feb 6, 2:39*pm, Some Bloke <ste...@lycos.co.uk> wrote:
> I'm still having problems with this. Right now I've added the line
> * * * * * * this._adapter.InsertCommand.UpdatedRowSource =
> System.Data.UpdateRowSource.None;
> to the InitAdapter() method in the generated TableAdapter.
>
> This means I have to be careful to replace it after making changes. I
> can't think how to do this in the partial class.
>
> Do Visual Studio's TableAdapters really offer no support for Batch
> Updates???


OK. I've added a property to the partial class. It does mean I have to
set it explicitly before doing an update but it will do the job.

public bool Batching
{
set
{
if (value)
{
_adapter.InsertCommand.UpdatedRowSource =
System.Data.UpdateRowSource.None;
_adapter.UpdateCommand.UpdatedRowSource =
System.Data.UpdateRowSource.None;
}
}
}

Hope this is useful to somebody.
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: Batch updates on generated TableAdapters throwsInvalidOperation<2418ff99-7a05-4e6c-a205-5578979d19c1@j20g2000hsi.googlegroups.com> Neeraj Saluja Microsoft ADO .NET 0 9th Apr 2008 11:48 AM
GetProcessByName throws InvalidOperation Exception : Access denied =?Utf-8?B?U2lsdmVyIE9haw==?= Microsoft Dot NET Framework 2 11th Feb 2006 09:24 PM
Synctoy throws "Application has generated an execption that could not be handled" James Windows XP Photos 0 20th Jan 2006 05:04 PM
Batch e-mail with customized html content in the body generated from asp.net webforms rgouge Microsoft ASP .NET 0 29th Jul 2005 09:23 PM
batch file auto-generated with each login rin Microsoft Windows 2000 1 11th Jun 2004 09:17 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:25 PM.