stored Procs or dataSet queries?

  • Thread starter Thread starter Andy B
  • Start date Start date
A

Andy B

Where would probably be the best place for queries to the database? in the
db as stroed procs or in the dataSet.
 
Hi,

The dataset is the result of a query to the DB :)

Maybe what you meant is a SP vs a query. Personally I prefer using SP. but
sometimes is easier to build the query, especially if you need some complex
combination of where/sort by clauses
 
Andy,

Personally, I prefer them in the database, as it makes them more
managable. Also, it provides an API layer in case you have to do
multiple-query work in the stored procedure to produce the output for your
query (as opposed to a single query that you are sending).
 
The TableAdapters are nice (ie, in the DataSet), but far more useful when
you can separate out the definition from the data access, which requires
..NET Framework 3.5/Visual Studio 2008. I generall do not head this
direction, but I am not against it, as it performs rather nicely.

If you go the database route, I would code as stored procedures. I know
there are others who will disagree with me on this, but it is easier, esp.
when learning, to secure sprocs than it is to secure code in objects served
up by a factory method, etc.

The stored procedure also acts as an abstraction as long as you are using a
relational server that allows sprocs, as you can change the driver/provider
and still query. This is not always true in practice, although it is in
theory (Oracle, for example, requires passing in a structure for output when
using the OracleClient objects).

One thing the abstraction does allow, however, is altering schema underneath
the sprocs, so you can version your database without impacting application
logic.

--
Gregory A. Beamer
MVP, MCP: +I, SE, SD, DBA

*************************************************
| Think outside the box!
|
*************************************************
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top