• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 496
  • Last Modified:

ASP.NET and Stored Procedures

I've been hard coding my stored procedure names each time it is required in the code-behind page, and of cause one can assign it to a private variable at page level, but I would like to know if there is a better, more acceptable practice amongst good ASP.NET Developers?

Thanks!
0
userTester
Asked:
userTester
  • 4
  • 2
1 Solution
 
käµfm³d 👽Commented:
Yes. You design your application using an n-tier architecture. Your UI (i.e. your code-behind) should know nothing about your data layer. What if you need to rename your sprocs? What if the database changes from SQL Server to Oracle? Things like this need to be accounted for when designing your application. Having an n-tier architecture helps mitigate major changes such as theses.

Some light reading:

0
 
userTesterAuthor Commented:
So the stored procedures are still hard-coded in the data access layer then?

Example from one of the links: command.CommandText = "GetClients";
0
 
userTesterAuthor Commented:
I really like these examples you provided, they help to put the design structure into perspective.

So thanks for a very helpful response to my question.
0
Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

 
userTesterAuthor Commented:
You understood my problem despite my poor explanation, so the perfect example of how an expert should answer a question.
0
 
käµfm³d 👽Commented:
So the stored procedures are still hard-coded in the data access layer then?
Effectively yes. Unless you are using some kind of ORM (like Entity Framework), then you would have to hard-code the proc names somewhere.
0
 
userTesterAuthor Commented:
Thanks for confirming that for me.

I must say that the CodeProject link example is especially helpful in more ways than expected. It's simple, clear, and the application runs as expected.

Because I initially had no real guide on how to do this project I am working on, I ended up doing so many long-winded unnecessary things, but now you've helped to clear up some things for me, especially from a design perspective.

Appreciate it, thanks!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

  • 4
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now