Solved

ASP.NET and Stored Procedures

Posted on 2013-06-22
6
471 Views
Last Modified: 2013-06-22
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
Comment
Question by:userTester
  • 4
  • 2
6 Comments
 
LVL 74

Accepted Solution

by:
käµfm³d   👽 earned 500 total points
ID: 39268811
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
 

Author Comment

by:userTester
ID: 39268867
So the stored procedures are still hard-coded in the data access layer then?

Example from one of the links: command.CommandText = "GetClients";
0
 

Author Comment

by:userTester
ID: 39268883
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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 

Author Closing Comment

by:userTester
ID: 39268886
You understood my problem despite my poor explanation, so the perfect example of how an expert should answer a question.
0
 
LVL 74

Expert Comment

by:käµfm³d 👽
ID: 39268917
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
 

Author Comment

by:userTester
ID: 39268938
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

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

In this article I will describe the Detach & Attach method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
In this article we will get to know that how can we recover deleted data if it happens accidently. We really can recover deleted rows if we know the time when data is deleted by using the transaction log.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now