PC Review


Reply
Thread Tools Rate Thread

Batch queries in stored procedures?

 
 
Guest
Posts: n/a
 
      25th Feb 2005
I'm using SQL Server stored procedures to access my tables, but I'm having
problems with concurrency violations when updating.

The ADO.NET Core Reference (Ch. 11, pg 469) says you can use batch queries
to retrieve data after submitting an update via a data adapter. Am I
correct in assuming this same concept be applied to stored procedures? If
so, a code example would be greatly appreciated.

For reference, here are the steps I took so far:
- Set DataAdapter.UpdateCommand.UpdatedRowSource = FirstReturnedRecord
- Added code to stored procedure to SELECT the updated record.
- Added code to update the database:
DataAdapter.Update(DataSet.DataTable.Select("", "", _
DataViewRowState.ModifiedCurrent))

Thank you,

Eric


 
Reply With Quote
 
 
 
 
William \(Bill\) Vaughn
Guest
Posts: n/a
 
      27th Feb 2005
Sure, I show how to do this in my book as well--and yes you can execute
stored procedures to post the update. Let's see your SP called by the
UpdateCommand.
What concurrency violations are you getting? What kind of concurrency
checking are you doing? Is the SP returning 1 for the rows affected value?

--
____________________________________
William (Bill) Vaughn
Author, Mentor, Consultant
Microsoft MVP
www.betav.com/blog/billva
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.
__________________________________

<Eric> wrote in message news:(E-Mail Removed)...
> I'm using SQL Server stored procedures to access my tables, but I'm having
> problems with concurrency violations when updating.
>
> The ADO.NET Core Reference (Ch. 11, pg 469) says you can use batch queries
> to retrieve data after submitting an update via a data adapter. Am I
> correct in assuming this same concept be applied to stored procedures? If
> so, a code example would be greatly appreciated.
>
> For reference, here are the steps I took so far:
> - Set DataAdapter.UpdateCommand.UpdatedRowSource = FirstReturnedRecord
> - Added code to stored procedure to SELECT the updated record.
> - Added code to update the database:
> DataAdapter.Update(DataSet.DataTable.Select("", "", _
> DataViewRowState.ModifiedCurrent))
>
> Thank you,
>
> Eric
>
>



 
Reply With Quote
 
Sahil Malik
Guest
Posts: n/a
 
      27th Feb 2005
Yes you can do multiple resultsets via sprocs.

Concurrency violation - I think you need to implement your own solution
around this. A chapter could be written about this, lets start at "How have
you implemented concurrency checks?"


- Sahil Malik
http://codebetter.com/blogs/sahil.malik/


<Eric> wrote in message news:(E-Mail Removed)...
> I'm using SQL Server stored procedures to access my tables, but I'm having
> problems with concurrency violations when updating.
>
> The ADO.NET Core Reference (Ch. 11, pg 469) says you can use batch queries
> to retrieve data after submitting an update via a data adapter. Am I
> correct in assuming this same concept be applied to stored procedures? If
> so, a code example would be greatly appreciated.
>
> For reference, here are the steps I took so far:
> - Set DataAdapter.UpdateCommand.UpdatedRowSource = FirstReturnedRecord
> - Added code to stored procedure to SELECT the updated record.
> - Added code to update the database:
> DataAdapter.Update(DataSet.DataTable.Select("", "", _
> DataViewRowState.ModifiedCurrent))
>
> Thank you,
>
> Eric
>
>



 
Reply With Quote
 
William \(Bill\) Vaughn
Guest
Posts: n/a
 
      28th Feb 2005
That's in the new book... (in progress).

--
____________________________________
William (Bill) Vaughn
Author, Mentor, Consultant
Microsoft MVP
www.betav.com/blog/billva
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.
__________________________________

"Sahil Malik" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Yes you can do multiple resultsets via sprocs.
>
> Concurrency violation - I think you need to implement your own solution
> around this. A chapter could be written about this, lets start at "How
> have you implemented concurrency checks?"
>
>
> - Sahil Malik
> http://codebetter.com/blogs/sahil.malik/
>
>
> <Eric> wrote in message news:(E-Mail Removed)...
>> I'm using SQL Server stored procedures to access my tables, but I'm
>> having
>> problems with concurrency violations when updating.
>>
>> The ADO.NET Core Reference (Ch. 11, pg 469) says you can use batch
>> queries
>> to retrieve data after submitting an update via a data adapter. Am I
>> correct in assuming this same concept be applied to stored procedures?
>> If
>> so, a code example would be greatly appreciated.
>>
>> For reference, here are the steps I took so far:
>> - Set DataAdapter.UpdateCommand.UpdatedRowSource = FirstReturnedRecord
>> - Added code to stored procedure to SELECT the updated record.
>> - Added code to update the database:
>> DataAdapter.Update(DataSet.DataTable.Select("", "", _
>> DataViewRowState.ModifiedCurrent))
>>
>> Thank you,
>>
>> Eric
>>
>>

>
>



 
Reply With Quote
 
Sahil Malik
Guest
Posts: n/a
 
      28th Feb 2005
COOL !! Be lookin' fwd. to buyin' it !! Who'se the publisher?

- Sahil Malik
http://codebetter.com/blogs/sahil.malik/





"William (Bill) Vaughn" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> That's in the new book... (in progress).
>
> --
> ____________________________________
> William (Bill) Vaughn
> Author, Mentor, Consultant
> Microsoft MVP
> www.betav.com/blog/billva
> 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.
> __________________________________
>
> "Sahil Malik" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > Yes you can do multiple resultsets via sprocs.
> >
> > Concurrency violation - I think you need to implement your own solution
> > around this. A chapter could be written about this, lets start at "How
> > have you implemented concurrency checks?"
> >
> >
> > - Sahil Malik
> > http://codebetter.com/blogs/sahil.malik/
> >
> >
> > <Eric> wrote in message news:(E-Mail Removed)...
> >> I'm using SQL Server stored procedures to access my tables, but I'm
> >> having
> >> problems with concurrency violations when updating.
> >>
> >> The ADO.NET Core Reference (Ch. 11, pg 469) says you can use batch
> >> queries
> >> to retrieve data after submitting an update via a data adapter. Am I
> >> correct in assuming this same concept be applied to stored procedures?
> >> If
> >> so, a code example would be greatly appreciated.
> >>
> >> For reference, here are the steps I took so far:
> >> - Set DataAdapter.UpdateCommand.UpdatedRowSource = FirstReturnedRecord
> >> - Added code to stored procedure to SELECT the updated record.
> >> - Added code to update the database:
> >> DataAdapter.Update(DataSet.DataTable.Select("", "", _
> >> DataViewRowState.ModifiedCurrent))
> >>
> >> Thank you,
> >>
> >> Eric
> >>
> >>

> >
> >

>
>



 
Reply With Quote
 
William \(Bill\) Vaughn
Guest
Posts: n/a
 
      28th Feb 2005
Addison Wesley Professional--same publisher as the Codd books.

--
____________________________________
William (Bill) Vaughn
Author, Mentor, Consultant
Microsoft MVP
www.betav.com/blog/billva
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.
__________________________________

"Sahil Malik" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> COOL !! Be lookin' fwd. to buyin' it !! Who'se the publisher?
>
> - Sahil Malik
> http://codebetter.com/blogs/sahil.malik/
>
>
>
>
>
> "William (Bill) Vaughn" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>> That's in the new book... (in progress).
>>
>> --
>> ____________________________________
>> William (Bill) Vaughn
>> Author, Mentor, Consultant
>> Microsoft MVP
>> www.betav.com/blog/billva
>> 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.
>> __________________________________
>>
>> "Sahil Malik" <(E-Mail Removed)> wrote in message
>> news:(E-Mail Removed)...
>> > Yes you can do multiple resultsets via sprocs.
>> >
>> > Concurrency violation - I think you need to implement your own solution
>> > around this. A chapter could be written about this, lets start at "How
>> > have you implemented concurrency checks?"
>> >
>> >
>> > - Sahil Malik
>> > http://codebetter.com/blogs/sahil.malik/
>> >
>> >
>> > <Eric> wrote in message news:(E-Mail Removed)...
>> >> I'm using SQL Server stored procedures to access my tables, but I'm
>> >> having
>> >> problems with concurrency violations when updating.
>> >>
>> >> The ADO.NET Core Reference (Ch. 11, pg 469) says you can use batch
>> >> queries
>> >> to retrieve data after submitting an update via a data adapter. Am I
>> >> correct in assuming this same concept be applied to stored procedures?
>> >> If
>> >> so, a code example would be greatly appreciated.
>> >>
>> >> For reference, here are the steps I took so far:
>> >> - Set DataAdapter.UpdateCommand.UpdatedRowSource = FirstReturnedRecord
>> >> - Added code to stored procedure to SELECT the updated record.
>> >> - Added code to update the database:
>> >> DataAdapter.Update(DataSet.DataTable.Select("", "", _
>> >> DataViewRowState.ModifiedCurrent))
>> >>
>> >> Thank you,
>> >>
>> >> Eric
>> >>
>> >>
>> >
>> >

>>
>>

>
>



 
Reply With Quote
 
Sahil Malik
Guest
Posts: n/a
 
      28th Feb 2005
If you consider me worthy of it, I'd love to review. !!

- Sahil Malik
http://codebetter.com/blogs/sahil.malik/



"William (Bill) Vaughn" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Addison Wesley Professional--same publisher as the Codd books.
>
> --
> ____________________________________
> William (Bill) Vaughn
> Author, Mentor, Consultant
> Microsoft MVP
> www.betav.com/blog/billva
> 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.
> __________________________________
>
> "Sahil Malik" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > COOL !! Be lookin' fwd. to buyin' it !! Who'se the publisher?
> >
> > - Sahil Malik
> > http://codebetter.com/blogs/sahil.malik/
> >
> >
> >
> >
> >
> > "William (Bill) Vaughn" <(E-Mail Removed)> wrote in message
> > news:(E-Mail Removed)...
> >> That's in the new book... (in progress).
> >>
> >> --
> >> ____________________________________
> >> William (Bill) Vaughn
> >> Author, Mentor, Consultant
> >> Microsoft MVP
> >> www.betav.com/blog/billva
> >> 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.
> >> __________________________________
> >>
> >> "Sahil Malik" <(E-Mail Removed)> wrote in message
> >> news:(E-Mail Removed)...
> >> > Yes you can do multiple resultsets via sprocs.
> >> >
> >> > Concurrency violation - I think you need to implement your own

solution
> >> > around this. A chapter could be written about this, lets start at

"How
> >> > have you implemented concurrency checks?"
> >> >
> >> >
> >> > - Sahil Malik
> >> > http://codebetter.com/blogs/sahil.malik/
> >> >
> >> >
> >> > <Eric> wrote in message news:(E-Mail Removed)...
> >> >> I'm using SQL Server stored procedures to access my tables, but I'm
> >> >> having
> >> >> problems with concurrency violations when updating.
> >> >>
> >> >> The ADO.NET Core Reference (Ch. 11, pg 469) says you can use batch
> >> >> queries
> >> >> to retrieve data after submitting an update via a data adapter. Am

I
> >> >> correct in assuming this same concept be applied to stored

procedures?
> >> >> If
> >> >> so, a code example would be greatly appreciated.
> >> >>
> >> >> For reference, here are the steps I took so far:
> >> >> - Set DataAdapter.UpdateCommand.UpdatedRowSource =

FirstReturnedRecord
> >> >> - Added code to stored procedure to SELECT the updated record.
> >> >> - Added code to update the database:
> >> >> DataAdapter.Update(DataSet.DataTable.Select("", "", _
> >> >> DataViewRowState.ModifiedCurrent))
> >> >>
> >> >> Thank you,
> >> >>
> >> >> Eric
> >> >>
> >> >>
> >> >
> >> >
> >>
> >>

> >
> >

>
>



 
Reply With Quote
 
David Sceppa
Guest
Posts: n/a
 
      2nd Mar 2005
Eric,

The approach does work, but I'd like to know a little more about the
problem you're seeing to make sure the example will cover your scenario.
When is the concurrency exception occurring? On the first update attempt,
or subsequent update attempts? Does the table contain server-generated
data - auto-increment, timestamp, defaults, etc.?

I'd recommend using output parameters over returning a row for
performance reasons.

David Sceppa
Microsoft
This posting is provided "AS IS" with no warranties,
and confers no rights. You assume all risk for your use.
© 2005 Microsoft Corporation. All rights reserved.

 
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
Batch of Stored Procedures mj2736@yahoo.com Microsoft Dot NET Framework 8 12th Mar 2008 01:56 PM
Batch of Stored Procedures mj2736@yahoo.com Microsoft ADO .NET 8 12th Mar 2008 01:56 PM
how can i convert stored procedures in sql to stored queries in ac =?Utf-8?B?YWRz?= Microsoft Access Queries 1 28th Aug 2006 01:49 PM
Batch execute Stored Procedures with sqlcommand? =?Utf-8?B?TGFycnkgQ2hhcmx0b24=?= Microsoft ADO .NET 0 2nd Mar 2006 11:11 AM
Executing multiple stored procedures in a single batch Venkatesh Microsoft ADO .NET 5 27th Aug 2003 10:19 PM


Features
 

Advertising
 

Newsgroups
 


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