Layered web project with ASP.NET
-
Hey guys, I have searched about this on the new and here but I'm still confused, so I'm gonna lay out this and hopefully with your help I can get it over with. I'm trying to design and implement a 3 layer web application, I want to fetch the info(fields such as name, email, ... ) for a student from Student table in my database: (consequently I want to do update, delete and insert as well) In my DAL class I fetch the record from database and return a dataset:
public DataSetFetchProfile(string UserName) { DataSet ThisDataSet = new DataSet(); ThisAd.SelectCommand = new SqlCommand("Profile_FetchStudentInfo", ThisConnection); ThisAd.SelectCommand.CommandType = CommandType.StoredProcedure; ThisAd.SelectCommand.Parameters.Add("@UserName", SqlDbType.NVarChar, 256).Value = UserName; ThisAd.Fill(ThisDataSet, "StudentT"); return ThisDataSet; }
and I have this function in my BLL class calling this one:public DataSet ReturnProfileInfo(string UserName) { return ThisStudent.FetchProfile(UserName); }
There are two things I might do in my presentaion layer (webpage), 1- populate some text boxes (fields of the record which was fetched) I use the following code:foreach (DataRow row in ThisDataSet.Tables["StudentT"].Rows) { //ThisStudent.FirstName = row["FirstName"].ToString(); }
2- populate a grid view ( which is easy by assigning its datasourse to the dataset which was returned) one thing is that the point of having 3 layered is not having any codes related to database, but I have to have a dataset in my page ! I have read a lot that this isn't such a good way of implementing 3 layer architecture, I'm working on my final project and I need something not too much confusing. I would really appreciate it if you could send me a sample of redirect me to a page ( again as I mentioned before, I 'm looking for something less confusing and easy to implement), so I can finish it and also learn something. Regards, K -
Hey guys, I have searched about this on the new and here but I'm still confused, so I'm gonna lay out this and hopefully with your help I can get it over with. I'm trying to design and implement a 3 layer web application, I want to fetch the info(fields such as name, email, ... ) for a student from Student table in my database: (consequently I want to do update, delete and insert as well) In my DAL class I fetch the record from database and return a dataset:
public DataSetFetchProfile(string UserName) { DataSet ThisDataSet = new DataSet(); ThisAd.SelectCommand = new SqlCommand("Profile_FetchStudentInfo", ThisConnection); ThisAd.SelectCommand.CommandType = CommandType.StoredProcedure; ThisAd.SelectCommand.Parameters.Add("@UserName", SqlDbType.NVarChar, 256).Value = UserName; ThisAd.Fill(ThisDataSet, "StudentT"); return ThisDataSet; }
and I have this function in my BLL class calling this one:public DataSet ReturnProfileInfo(string UserName) { return ThisStudent.FetchProfile(UserName); }
There are two things I might do in my presentaion layer (webpage), 1- populate some text boxes (fields of the record which was fetched) I use the following code:foreach (DataRow row in ThisDataSet.Tables["StudentT"].Rows) { //ThisStudent.FirstName = row["FirstName"].ToString(); }
2- populate a grid view ( which is easy by assigning its datasourse to the dataset which was returned) one thing is that the point of having 3 layered is not having any codes related to database, but I have to have a dataset in my page ! I have read a lot that this isn't such a good way of implementing 3 layer architecture, I'm working on my final project and I need something not too much confusing. I would really appreciate it if you could send me a sample of redirect me to a page ( again as I mentioned before, I 'm looking for something less confusing and easy to implement), so I can finish it and also learn something. Regards, KYou've done the right thing, you can have dataset, datatable or class object (orm) in your page, otherwise you can implement your requirement! Let me ask you something, can you tell me what db you're using by looking at ds, dt or object? No, you can't because that's independent of actual database your ds,dt doesn't know from what type of db they're getting data.
Please don't forget to mark 'Good Answer', if you find it really a good one! Kashif