PC Review


Reply
Thread Tools Rate Thread

converting tableAdaptor queries into stored procs

 
 
Andy B
Guest
Posts: n/a
 
      30th Nov 2007
Is there an easy way to convert tableAdaptor queries into stored procs
without messing up the dataTables in the dataSet or losing the queries
themselves?


 
Reply With Quote
 
 
 
 
Nicholas Paldino [.NET/C# MVP]
Guest
Posts: n/a
 
      30th Nov 2007
Andy,

Well, you will have to change the table adapters to work with the stored
procedure now and not the queries themselves.

This means that you will have to take the queries that are in the table
adapters and then move them to your database, parameterizing them correctly
(in the case of insert, delete, and update queries) and then changing the
commands on the table adapter to call the appropriate stored procedures.

And all of this you have to do by hand.

Do you have a specific reason you want to make them into stored
procedures? Unless you are adding more complex logic to the operation, you
really aren't getting that much of a benefit.

--
- Nicholas Paldino [.NET/C# MVP]
- (E-Mail Removed)

"Andy B" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Is there an easy way to convert tableAdaptor queries into stored procs
> without messing up the dataTables in the dataSet or losing the queries
> themselves?
>



 
Reply With Quote
 
Andy B
Guest
Posts: n/a
 
      30th Nov 2007
The queries are quite involved really. The ones I have in the tableAdaptors
only go to the point of subqueries. The insert, update and delete queries
are a different story. The biggest problem would be the insert and update
queries. We will start off with delete since its easier to deal with. I have
to delete rows from 2 different tables: NewsArticles and NewsHeaders. The
newsHeaders table has a reference to the newsId and CategoryId so to delete
the categories for a news article it would be: delete from NewsHeaders where
NewsId=@NewsID. Then move on to delete the news article itself: delete from
NewsArticles where NewsID=@NewsID. Now for insert and update. I will cover
insert since update is close enough to insert anyways. I have to take a
NewsCategoryCollection I created in C# and loop through it inserting the
CategoryID and the associated NewsId into NewsHeaders (there can be multiple
categories for a news article). I have this NewsCategoriesCollection linked
to a NewsArticle object that has the NewsID in it. After the
NewsCategoryCollection is inserted into NewsHeader, I insert the rest of the
news article into NewsArticles table. Sounds complicated and maybe I'm
explaining it the wrong way but hope it helps ....If you need to know more
let me know...


"Nicholas Paldino [.NET/C# MVP]" <(E-Mail Removed)> wrote in
message news:(E-Mail Removed)...
> Andy,
>
> Well, you will have to change the table adapters to work with the
> stored procedure now and not the queries themselves.
>
> This means that you will have to take the queries that are in the table
> adapters and then move them to your database, parameterizing them
> correctly (in the case of insert, delete, and update queries) and then
> changing the commands on the table adapter to call the appropriate stored
> procedures.
>
> And all of this you have to do by hand.
>
> Do you have a specific reason you want to make them into stored
> procedures? Unless you are adding more complex logic to the operation,
> you really aren't getting that much of a benefit.
>
> --
> - Nicholas Paldino [.NET/C# MVP]
> - (E-Mail Removed)
>
> "Andy B" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>> Is there an easy way to convert tableAdaptor queries into stored procs
>> without messing up the dataTables in the dataSet or losing the queries
>> themselves?
>>

>
>



 
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
LINQ Queries vs Stored Procs Frank Calahan Microsoft C# .NET 19 9th Jan 2008 09:45 AM
using mulbiple queries in a single tableAdaptor function? Andy B Microsoft C# .NET 0 2nd Dec 2007 10:40 PM
stored Procs or dataSet queries? Andy B Microsoft C# .NET 4 29th Nov 2007 05:11 PM
Using two stored procs instead of two queries? Roy Microsoft ASP .NET 2 27th Jan 2006 09:35 PM
Stored Procs Rob Microsoft VB .NET 5 22nd Nov 2005 07:34 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 04:42 AM.