[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

N-Tier sample

Posted on 2012-12-27
1
Medium Priority
?
163 Views
Last Modified: 2013-01-10
What would DAL and BAL looks like if there a subroutine that retreives data from sql, using sqldatareader, and display on textboxes and lables?

using sqlconnect as new sqlconnection("mycon string")
using sqlcomnd as new sqlcommand("mysp", sqconnect)
sqlcomnd.commandtype = commandtype.storeprocedure
sqlcomnd .parameters.addwithvalue("@id", ????)
dim dr as sqldatareader = sqlcomnd.exedutereader
dr.read

txtfirstname.text = dr.item("firstname")

etc...

end using
end using


http://www.mindstick.com/Articles/d36ceb0f-018c-4979-b2f5-a4a1e616cb5b/?N-Tier%20Architecture%20in%20ASP.NET
0
Comment
Question by:VBdotnet2005
[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
1 Comment
 
LVL 16

Accepted Solution

by:
Stephan earned 2000 total points
ID: 38726545
What I mostly do is the following:

- Create a library for the DataLayer
- Create a library for the BusinessLayer
- Create a project for the PresentationLayer

If you want to use the SqlCommand etc.. You put this in the datalayer. From the busineslayer you connect to the datalayer and ask for information (or save whatsoever).

The data you receive like a single datareader, I use this as parameter:
public T SomeMethod<T>(Func<IDataRecord, T> add) where T : class

And inside the call for loading, returning the data:
T record = default(T);
            using (SqlDataReader reader = cmd.ExecuteReader())
            {
                if (reader.Read())
                {
                    record = add(reader);
                }
            }

In this way you can use an delegate to tell the datalayer how you want to receive your data. For suggestion a Model. You create models in your domain (you can put it in the BusinessLayer). And you can fill them from the datalayer end.
Just when you call the SomeMethod(), you can do the following:

Person perso = DataLayer.SomeMethod(x => new Person(x));

Inside the model you create a constructor which accepts IDataRecord, from there you can get the data you need.

In this way you can fill your model and keep that separation of concern.

Now you can pass it on to the presentation layer.
I think from there it makes sense.
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …

656 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