Solved

ASP.NET and Stored Procedures

Posted on 2013-06-22
6
473 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 75

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
Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

 

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 75

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

SQL Server engine let you use a Windows account or a SQL Server account to connect to a SQL Server instance. This can be configured immediatly during the SQL Server installation or after in the Server Authentication section in the Server properties …
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
This tutorial demonstrates a quick way of adding group price to multiple Magento products.
A simple description of email encryption using a secure portal service. This is one of the choices offered by The Email Laundry for email encryption. The other choices are pdf encryption which creates an encrypted pdf of your email and any attachmen…

911 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

22 Experts available now in Live!

Get 1:1 Help Now