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

x
?
Solved

ASP.NET C# - Passing data between layers

Posted on 2004-04-20
6
Medium Priority
?
3,001 Views
Last Modified: 2011-02-24
Hi,

I'm building a system where
aspx and code behind are my presentation layer ( validation happens in code behind ),
the application logic is in separate classes,
the data access logic is in separate classes.

Most of the time I will need to access one row ( usually joined tables ) at a time - except for read-only reports.

Is it possible to create empty DataSet in the application layer and populate it with data ( one row ), then pass it to data layer which uses this DataSet to update the DB?

Overall I'm looking for a more elegant sollution than passing SQL statments...


I'm willing to incrase points if I am able to use the sollution...also If you could provide me with a better architecture ( with examples ) I could use I'm willing to give extra points.

please ask if the question is not clear

thanks
0
Comment
Question by:Crazee
[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
  • 3
  • 3
6 Comments
 
LVL 29

Expert Comment

by:David H.H.Lee
ID: 10875552
Crazee,
>>Most of the time I will need to access one row ( usually joined tables ) at a time - except for read-only reports.
-If the server allow, you can store all the data into dataview first. After that, you can use RowFilter(built in function inside dataview itself) to filter the desired output based on the previous retrieved data. Now, you can access one row or every row(eg:except for read-only reports) at the same time without retrieve data from server everytime.

>>Is it possible to create empty DataSet in the application layer and populate it with data ( one row ), then pass it to data layer which uses this DataSet to update the DB?
-Are you looking for some action like you want to get the data from dataset and update the dataset in the same time? Corret me if i misunderstand your question. If this is your problems, why don't you just use SqlCommandBuilder to overcome this problem instead of create an additional dataset and passing to data layer and update the dataset? I only think this method can retrieve data and update the dataset at the same time.

Hope this help. If this not clear, please give more explanations about what you want to accomplish.



0
 
LVL 2

Author Comment

by:Crazee
ID: 10885542
I'm looking for a good way of passing data between the classes. Most of the time I will need data to populate one instance of an object.
I know that if you retrieve data from db you can pass it in a form of DataSet or DataReader. In that case if you get input from the user, can you create an empty DataSet and populate it with data received from the user? I'm fairly new to .NET so the whole concept may be wrong.
0
 
LVL 29

Expert Comment

by:David H.H.Lee
ID: 10885684
Crazee.
Since you're using 3-tier development, you should be able solve this kind of problem easily. Ok, now i want to ask one more question before give you the whole idea of the solutions.

>>can you create an empty DataSet and populate it with data received from the user
-Why you so interest create an empty Dataset and populate with data received from user? Can i know the purpose? Possible for you give me the exact senario. More details about this. Normally, i like to use DataView to filter(use RowFilter) what i'm need.
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 2

Author Comment

by:Crazee
ID: 10894947
I don't have to use DataSets this way. I just thought that if it can be used to pass data from DB, maybe I could use it to pass data to DB as well - I know that it's possible to update existing DataSet, but I was thinking of creating an empty one.

The point of my question was weather my logic was right, and if not - I would like to find another solution.

Let's have a sample scenario.

Add Project:

User chooses to add new project
Fills the form
Submited data is validated in code behind and if is ok - new class Project is created and populated with this data
Class Project calls save() method of another class that can access DB

here's the question: what should I pass in the save() method?

What would be the case with Edit Project if I have to grab the data from the DB first?

if it's not clear please ask

0
 
LVL 29

Accepted Solution

by:
David H.H.Lee earned 1000 total points
ID: 10929489
Sorry for my delay, Crazee.

-Crazee, i tell you what i done in 3-tier development. I will create 3 layer
Presentation Layer, Business Layer and Data Layer like what you had done.
Presentation Layer - contains all web/html code
Business Layer - contains all business component(include classes, all the operations will be return here)
Data Layer - only use to access your db(insert, update,delete,..etc)

>>what should I pass in the save() method?
-I will put it in Data Layer. You can call this function from your predefined classes. If you need to pass somethings to the business layer, you'll need to assign it into your object variable.
eg:
Car sportCar;
sportCar=new Car();
sportCar.Number="ASC 8888";
sportCar.Save();
However, if you like to pass variables that you think not include inside business layer, you can pass it as local parameter inside save() method.
eg:
sportCar.Save(yourVariableName);

>>What would be the case with Edit Project if I have to grab the data from the DB first?
-You always can grab the db first no matter it edit mode or read-only mode. Please give more details about what you trying to do with this problem.

Crazee, if you want exact solutions, it's better you give the exact senario instead of this example.

If you already get what the solutions before my comments, you can request to close it at Community Support. Admin will handle it else i'll glad to continue this thread as well.

Regards
x_com

0
 
LVL 2

Author Comment

by:Crazee
ID: 10956498
I got it working.

I'm passing data between classes using data sets instead of assigning data to properties.
( if you're interested I can post more details )

Basically what I was looking for was a theoretical discussion on possible architecture and the way of passing data.
You provided me with your sollution and although I'm not going to use it, I appreciate your time.

cheers
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:   The Exchange of informatio…
Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
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, …

649 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