Solved

ASP.NET and Stored Procedures

Posted on 2013-06-22
6
481 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
Backup Solution for AWS

Read about how CloudBerry Backup fully integrates your backups with Amazon S3 and Amazon Glacier to provide military-grade encryption and dramatically cut storage costs on any platform.

 

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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Update one rows based on previous row 5 27
Insert msdb.dbo.sysmail_event_log Process_ID into table 4 37
SQL server client app 3 25
SQL syntax question 6 30
In this article I will describe the Backup & Restore 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.
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

685 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