469,945 Members | 2,262 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,945 developers. It's quick & easy.

converting tableAdaptor queries into stored procs

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?
Nov 30 '07 #1
2 1550
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]
- mv*@spam.guard.caspershouse.com

"Andy B" <a_*****@sbcglobal.netwrote in message
news:et**************@TK2MSFTNGP04.phx.gbl...
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?

Nov 30 '07 #2
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]" <mv*@spam.guard.caspershouse.comwrote in
message news:OY**************@TK2MSFTNGP03.phx.gbl...
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]
- mv*@spam.guard.caspershouse.com

"Andy B" <a_*****@sbcglobal.netwrote in message
news:et**************@TK2MSFTNGP04.phx.gbl...
>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?


Nov 30 '07 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

6 posts views Thread by Dave | last post: by
4 posts views Thread by Andy B | last post: by
8 posts views Thread by Frank Calahan | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.