H
headware
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
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