473,394 Members | 1,797 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

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.InsertCustomer(name, age, phone);
or
DataSet custDS = webService.GetAllCustomers();
or
webService.UpdateCustomer(custId, 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("");
OleDbDataAdapter adapter = new OleDbDataAdapter("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 2188
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.com> wrote in message
news:e3**************************@posting.google.c om...
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.InsertCustomer(name, age, phone);
or
DataSet custDS = webService.GetAllCustomers();
or
webService.UpdateCustomer(custId, 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("");
OleDbDataAdapter adapter = new OleDbDataAdapter("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.netNoSpamM> wrote in message news:<#K**************@tk2msftngp13.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.com> wrote in message
news:e3**************************@posting.google.c om...
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.InsertCustomer(name, age, phone);
or
DataSet custDS = webService.GetAllCustomers();
or
webService.UpdateCustomer(custId, 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("");
OleDbDataAdapter adapter = new OleDbDataAdapter("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
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
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...
1
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...
13
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...
4
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...
2
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...
5
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...
6
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...
9
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...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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...
0
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.