Click here to Skip to main content
15,877,168 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi All,

I am new to 3-Tier architecture.
Can anyone help me where(I mean which layer) to declare and how to declare parameters for sql server stored procedure.
I am using stored procedure to insert values into the table.
Suppose my SP is
SQL
create procedure sp_insert
@fname varchar,
@lname varchar
As
Begin
Insert into emp(firstname,lastname) values(@fname,@lname);
End


Now using asp.net web form, I am inserting values into the table.
Here in web form I have two textboxes txtfirstname and txtlastname and a button.
Can anyone tell me the code to be written in each layer mailny variable/parameters declaration.
I went through many articles but getting confusion.

Just I need rough sketch of each layer code to be written for this example.

Thank you,
Posted

1 solution

You have already asked a couple questions about 3-tiered architecture and how to accomplish it. Each question has received good answers and tutorials. Each time you ask fairly open-ended questions that are difficult to answer specifically. My suggestion would be to find a good book or video series on how to architect applications. For example, Pluralsight[^] has a great video training library for this type of application development. It isn't free but it is definitely worth it.

I don't want to sound like I'm avoiding your questionm, but in a way I guess I am. The reason is that usually it depends is the best possible answer. For instance, I would say that probably those variables would get put together in the business layer but I have also built them in the User Interface layer and in the data access layer. It all depends on the circumstances, which makes it impossible for me to give you a specific answer.

As to how to call the stored procedure using those parameters, this tutorial will help:

http://www.csharp-station.com/Tutorial/AdoDotNet/lesson07[^]
 
Share this answer
 
Comments
palcordis 15-Jun-12 10:32am    
Ye I am also having some confusion regarding this same type of query.
If anyone can help its really appreciated.
Tim Corey 15-Jun-12 10:39am    
The link I posted in my answer has a walkthrough on how to execute a stored procedure with parameters. It should answer all of your questions.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900