Solved

ASP.NET and Stored Procedures

Posted on 2013-06-22
6
485 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Edgartown IT Case Study

Learn about Edgartown's quest to ensure the safety and security of the entire town's employee and citizen data. Read the case study!

 

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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Shared Service Environment 2 51
Data Analysis 7 57
Textbox autocomplete using jquery in asp.net 13 42
Need a quick overview of Selenium testing 2 32
Occasionally there is a need to clean table columns, especially if you have inherited legacy data. There are obviously many ways to accomplish that, including elaborate UPDATE queries with anywhere from one to numerous REPLACE functions (even within…
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.
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

740 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