-2

I went through and spent all my time on almost all links and sources about these topics: BUSINESS LAYER, PRESENTATION LAYER, DATA ACCESS LAYER. But still i don't understand it because different sources, different usage, it confuses me a lot. Now this is my final try to understand it. Help me. I am writing piece of code so Please categorize it in respective layers and provide little bit explanation if possible. Thanks.

.aspx

<asp:textbox id="txtName" runat="server"/>
<asp:textbox id="txtPwd" runat="server"/>
<asp:button id="txtButton" runat="server" />

.cs

String selectQuery= "Select * from tblUser where id="'+txtName.Text+"'";
String ConStr = "string to connect database":
SqlConnection sqlCon = new sqlconnection(ConStr);
SqlCommand sqlCom = new sqlCommand(selectQuery, sqlCon);
SqlDataAdapter sqlDA = new SqlDataAdapter(sqlCom);
DataSet ds = new DataSet();
sqlDA.Fill(ds);

try
{}
catch(....)
{}

Please help.

user3432348
  • 353
  • 1
  • 5
  • 9

2 Answers2

0

You should try and find some good tutorials about creating n-tier applications. I know there's one or two at pluralsight website. It covers what you are asking here.

The file with .aspx extension in your case is responsible for rendering a view. So it's categorized as a presentation layer.

The second one with .cs extension is looking like it's trying to access the database. So it could be categorized as a data access layer.

The business layer make use of your data access layer and DoStuff()...:) In n-tier applications when you are working on a project (e.g. MVC application) it should make use of business logic not data access. To simply put, your application should not know anything about accessing the data.

Hope it helps you a little a least.

rosko
  • 464
  • 3
  • 16
0

It can be confusing at first and more difficult to implement. You may want to read an article I posted on Layered Architecture. http://serena-yeoh.blogspot.com/2013/06/layered-architecture-for-net.html

From there, you can also link to other articles in the series.

Once, you have the concepts, you may want to take a look at the Layered Architecture Samples for .NET in http://layersample.codeplex.com/ You should be able to find samples that uses a variety of .NET technologies of today.

Finally, if you are looking for fast adoption, you may want to check out the Layered Architecture Solution Guidance (LASG) visual studio extension. http://layerguidance.codeplex.com/