473,903 Members | 3,914 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

interfacing with data layer

I'm relatively new to ASP.NET and ADO.NET, but I have a basic design
question regarding the use of web services and APS.NET applications.
Right now we have an application that uses web services to access the
database layer. However, the code works in a pretty cumbersome and
ungeneric way. Basically every query, update, and insert has its own
[WebMethod] function. So you see a lot of functions like

webService.Inse rtCustomer(name , age, phone);
or
DataSet custDS = webService.GetA llCustomers();
or
webService.Upda teCustomer(cust Id, name, age, phone);

I have my doubts about whether this is the best way to be interfacing
with the data layer. Couldn't you store the customer currently being
worked on (assuming you have a page in which you can work on the data
for a single customer at a time) in a DataSet stored in the Session
object and send that DataSet back to the data later so the DataAdapter
can call the Update() method on it? Unless I'm missing something, that
should allow you to have only one web service function for inserting,
deleting, and updating any table in the database. For example, you
could update the database like this

[WebMethod]
public void UpdateDatabase( DataSet ds)
{
OleDbConnection connection = new OleDbConnection ("");
OleDbDataAdapte r adapter = new OleDbDataAdapte r("SELECT * FROM " +
ds.Tables[0].TableName, connection);
adapter.Update( ds);
}

As long as the DataSet rows have the proper rowstate values, this one
function should do all your inserting, updating, and deleting for you,
right?

Of course, you'd have to be careful about storing large DataSets in
the Session object for the sake of scalability. In our particular
application, there would never be all that many users logged on at any
given point so I don't think that should be an issue.

What I'm really getting at here is that I would like
ideas/experience/articles/books about how people interface with the
data layer in ASP.NET applications.

Thanks,
Dave
Nov 18 '05 #1
2 2218
Let's look at the purpose of web services, whether ASMX or Remoting, which
is a transport mechanism. This mechanism can sit between the Business layer
and the data layer or the data layer and the UI. Ultimately, the core of the
data layer is more generic, like the Microsoft Data Access Application
Block. There are times you will have more specific data elements on the data
layer, like strongly typed DataSet definitions with their data access
methods (which use the generic data tier) and other times, the business
rules will be more of a driver (indicating the sproc used to access data,
for example).

In your model, you can have the web method stay as is, but add something
more generic on another data tier. The Data Access Application Block is not
a bad choice, as it is free and the code is already written for you. There
is an error in the FillDataSet() method where the table mapping names are
linked to the generic names created when the DataSet is filled, but it is
not too hard to edit.

Now, to where the web service should be.

If you have an "app server" that also hosts your data access code, you will
have web services as the transport between web server (UI) and app (business
layer). If you are dealing with web server, app server and data server, you
may end up with web services at both spots, although the Remoting type
perform better. NOTE that it is unusual to have two web services layers in
your app model. More common, you will see database server with business
rules and data on the same server, as filtered data (data that has passed
through some form of business rules component(s)) is more common, esp. since
you often see web services used for Extranet situations.

Another option is setting up your assemblies to go inside COM+ and
distributing your application that way.

I realize this is more theory than anything else, but I hope it gives you
some ideas.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

*************** *************** *************** ****
Think outside the box!
*************** *************** *************** ****
"headware" <he******@aol.c om> wrote in message
news:e3******** *************** ***@posting.goo gle.com...
I'm relatively new to ASP.NET and ADO.NET, but I have a basic design
question regarding the use of web services and APS.NET applications.
Right now we have an application that uses web services to access the
database layer. However, the code works in a pretty cumbersome and
ungeneric way. Basically every query, update, and insert has its own
[WebMethod] function. So you see a lot of functions like

webService.Inse rtCustomer(name , age, phone);
or
DataSet custDS = webService.GetA llCustomers();
or
webService.Upda teCustomer(cust Id, name, age, phone);

I have my doubts about whether this is the best way to be interfacing
with the data layer. Couldn't you store the customer currently being
worked on (assuming you have a page in which you can work on the data
for a single customer at a time) in a DataSet stored in the Session
object and send that DataSet back to the data later so the DataAdapter
can call the Update() method on it? Unless I'm missing something, that
should allow you to have only one web service function for inserting,
deleting, and updating any table in the database. For example, you
could update the database like this

[WebMethod]
public void UpdateDatabase( DataSet ds)
{
OleDbConnection connection = new OleDbConnection ("");
OleDbDataAdapte r adapter = new OleDbDataAdapte r("SELECT * FROM " +
ds.Tables[0].TableName, connection);
adapter.Update( ds);
}

As long as the DataSet rows have the proper rowstate values, this one
function should do all your inserting, updating, and deleting for you,
right?

Of course, you'd have to be careful about storing large DataSets in
the Session object for the sake of scalability. In our particular
application, there would never be all that many users logged on at any
given point so I don't think that should be an issue.

What I'm really getting at here is that I would like
ideas/experience/articles/books about how people interface with the
data layer in ASP.NET applications.

Thanks,
Dave

Nov 18 '05 #2
Thanks for the response. The more I think about the situation the more
I think that the correct solution is to build a business layer between
the UI and the database. Doing that would make the issues I brought up
in the first post mostly moot.

I checked out the ASP.NET Alliance start kits (found at
http://www.asp.net/Default.aspx?tabindex=9&tabid=47). The two that I
have downloaded and looked at are set up as 3-tiered systems with
ASP.NET as the UI, a set of classes to perform the business logic, and
SQL Server Stored Procs as the data access tier. Seems like a pretty
good separation except for the fact that the business tier is
dependent on ADO.NET since it instantiates classes like SqlDataAdapter
to call the Stored Procs. The UI layer is also dependent on ADO.NET
since it uses the DataSets and DataReaders the business layer returns.
Is that considered good practice? I realize that it would probably be
difficult to totally separate the technologies used from the different
layers of the application. I suppose you'd have to come up with your
own classes for sharing the data between layers. Is that done often?

Dave

"Cowboy \(Gregory A. Beamer\)" <No************ @comcast.netNoS pamM> wrote in message news:<#K******* *******@tk2msft ngp13.phx.gbl>. ..
Let's look at the purpose of web services, whether ASMX or Remoting, which
is a transport mechanism. This mechanism can sit between the Business layer
and the data layer or the data layer and the UI. Ultimately, the core of the
data layer is more generic, like the Microsoft Data Access Application
Block. There are times you will have more specific data elements on the data
layer, like strongly typed DataSet definitions with their data access
methods (which use the generic data tier) and other times, the business
rules will be more of a driver (indicating the sproc used to access data,
for example).

In your model, you can have the web method stay as is, but add something
more generic on another data tier. The Data Access Application Block is not
a bad choice, as it is free and the code is already written for you. There
is an error in the FillDataSet() method where the table mapping names are
linked to the generic names created when the DataSet is filled, but it is
not too hard to edit.

Now, to where the web service should be.

If you have an "app server" that also hosts your data access code, you will
have web services as the transport between web server (UI) and app (business
layer). If you are dealing with web server, app server and data server, you
may end up with web services at both spots, although the Remoting type
perform better. NOTE that it is unusual to have two web services layers in
your app model. More common, you will see database server with business
rules and data on the same server, as filtered data (data that has passed
through some form of business rules component(s)) is more common, esp. since
you often see web services used for Extranet situations.

Another option is setting up your assemblies to go inside COM+ and
distributing your application that way.

I realize this is more theory than anything else, but I hope it gives you
some ideas.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

*************** *************** *************** ****
Think outside the box!
*************** *************** *************** ****
"headware" <he******@aol.c om> wrote in message
news:e3******** *************** ***@posting.goo gle.com...
I'm relatively new to ASP.NET and ADO.NET, but I have a basic design
question regarding the use of web services and APS.NET applications.
Right now we have an application that uses web services to access the
database layer. However, the code works in a pretty cumbersome and
ungeneric way. Basically every query, update, and insert has its own
[WebMethod] function. So you see a lot of functions like

webService.Inse rtCustomer(name , age, phone);
or
DataSet custDS = webService.GetA llCustomers();
or
webService.Upda teCustomer(cust Id, name, age, phone);

I have my doubts about whether this is the best way to be interfacing
with the data layer. Couldn't you store the customer currently being
worked on (assuming you have a page in which you can work on the data
for a single customer at a time) in a DataSet stored in the Session
object and send that DataSet back to the data later so the DataAdapter
can call the Update() method on it? Unless I'm missing something, that
should allow you to have only one web service function for inserting,
deleting, and updating any table in the database. For example, you
could update the database like this

[WebMethod]
public void UpdateDatabase( DataSet ds)
{
OleDbConnection connection = new OleDbConnection ("");
OleDbDataAdapte r adapter = new OleDbDataAdapte r("SELECT * FROM " +
ds.Tables[0].TableName, connection);
adapter.Update( ds);
}

As long as the DataSet rows have the proper rowstate values, this one
function should do all your inserting, updating, and deleting for you,
right?

Of course, you'd have to be careful about storing large DataSets in
the Session object for the sake of scalability. In our particular
application, there would never be all that many users logged on at any
given point so I don't think that should be an issue.

What I'm really getting at here is that I would like
ideas/experience/articles/books about how people interface with the
data layer in ASP.NET applications.

Thanks,
Dave

Nov 18 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
1225
by: Kunal | last post by:
Hello I am trying to create/read data from MS Access using C. Can anybody suggest "must read" references or links? Thanks for your help. Regards Kunal Lagwankar
5
2141
by: Kevin C | last post by:
I was curious to know what some developers out in the industry are doing when it comes to exposing Data access logic, specifically persistence. This is assuming that your not using an O/R framework or something that completely abstracts you from the persistence details. Are you: 1. Having simple data type interfaces and the data layer know nothing about the domain models. For example: public int SaveCustomer( string fname, string...
1
2594
by: Johann Blake | last post by:
I am looking for a good solution on how to implement data access in an application so that there is a clean separation between the data access layer, the business layer and the GUI layer. I am looking for a robust solution for a major application. Almost every developer seems to come up with a completely different solution. While many of them are not bad, I really want a very good one. My database is SQL Server 2000 and I am using Visual...
13
3130
by: Alan Silver | last post by:
Hello, MSDN (amongst other places) is full of helpful advice on ways to do data access, but they all seem geared to wards enterprise applications. Maybe I'm in a minority, but I don't have those sorts of clients. Mine are all small businesses whose sites will never reach those sorts of scales. I deal with businesses whose sites get maybe a few hundred visitors per day (some not even that much) and get no more than ten orders per day....
4
3027
by: pratham | last post by:
Hi! I'm making a database application and i heard from a friend that it is more proffecional and easy to do this with bussines objects. Can anyone tell me where i can find more info on bussines objects and how to implement them with c#? I would appreciate any help. How can i decide that what things go into business layer and what
2
1938
by: Ily | last post by:
Hi all I am using Visual studio 2005. Im my project I have a presentation layer, a business layer and a data access layer. From my business layer i have a reference to my data layer. I also have a refeence to my business layer from my presentation layer. Now the weird thing is, I can create a form, and I can add a using
5
1384
by: AAJ | last post by:
Hi all FIRST THE BORING BITS....... I normally use a Database layer, a Business layer and a GUI layer. The GUI uses an Object data source to bind to the Business layer which in turn binds to the database layer. Every thing is great. I can read data, change data in the grid, update the database, and when the GUI reloads, all the changes are all present and correct. i.e. the data seems to be persisted
6
14162
by: Dhananjay | last post by:
hello everyone i have got a problem i want to design business layer, data access layer , presentation layer for asp.net using C#.net , can anyone help me to solve this problem. i want some resources to complete this. i am trying very hard. Do you have any idea about website or any links where i can find some examples based on this concept.can you plz provide me , its urgent i want this solution with an example, if u have plz provide me. ...
9
2749
by: SAL | last post by:
Hello, I have a Dataset that I have table adapters in I designed using the designer (DataLayer). I have a business logic layer that immulates the DataLayer which may/may not have additional logic in. My business classes are, of course, decorated with the: <System.ComponentModel.DataObject() attribute. So, I drop a GridView on a webform and set its datasource to an ObjectDatasource which in turn is using one of my business logic...
0
10873
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10983
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9684
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
7206
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5894
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
6088
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4726
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4308
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3324
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.