On Aug 29, 1:30 pm, "Cor Ligthert[MVP]" <notmyfirstn...@planet.nl>
[quoted text, click to view] wrote:
> Kittipong,
>
> It depends on the project, however I do it for larger project as you told.
> However it is even possible to set your simple checkings in the field
> descriptors in the SQL server, that is then exposed in the strongly typed
> dataset which makes then an easy early check even automatically in the UI
> possible, as it is about binded controls.
>
> The cavatat of that is that it needs forever maintenance at the SQL server
> side. I agree with you that this all does not make everything clear.
>
> Cor
>
> <kittipong.kiatcheera...@gmail.com> schreef in berichtnews:1188349576.118470.74270@x35g2000prf.googlegroups.com...
>
> >I am not exactly sure that my understanding is right or wrong. In
> > strongly typed dataset we can generate all of the fields from tables
> > in database and also has tableadapter that allow us to write down sql
> > command in or directly link to table. We still can write the code in
> > dataset partial class for validating data as well.
> > As far as I understand strongly typed dataset is in both of Business
> > layer and data access layer, isn't it? Because validation rules code
> > and all datatable's fields should be in business layer and
> > tableadapter which is tied to sql command and connection string should
> > be in data access layer. Is this right or wrong? Any suggestion or
> > does it have any best way if I want to use strongly typed dataset in
> > my project.
Thanks for the answer Cor. I still have a thing that confusing me. For
DataAccess Layer should it know about StronglyTyped dataset? For
example, I have a insert product method in my Data Access Layer as the
first method below:
1. First Method:
public static int Insert(string productName, int categoryID, decimal
unitPrice)
{
Database myDatabase = DatabaseFactory.CreateDatabase();
DBCommandWrapper myCommand =
myDatabase.GetStoredProcCommandWrapper("entlibProductsInsert");
myCommand.AddInParameter("@ProductName", DbType.String,
productName);
myCommand.AddInParameter("@CategoryID", DbType.Int32, categoryID);
myCommand.AddInParameter("@UnitPrice", DbType.Currency, unitPrice);
// Execute the query and return the new identity value
return Convert.ToInt32(myDatabase.ExecuteScalar(myCommand));
}
2. Second Method:
public static int Insert(ProductDataSet productDataSet)
{
Database myDatabase = DatabaseFactory.CreateDatabase();
DBCommandWrapper myCommand =
myDatabase.GetStoredProcCommandWrapper("entlibProductsInsert");
myCommand.AddInParameter("@ProductName", DbType.String,
productName);
myCommand.AddInParameter("@CategoryID", DbType.Int32, categoryID);
myCommand.AddInParameter("@UnitPrice", DbType.Currency, unitPrice);
// Execute the query and return the new identity value
return Convert.ToInt32(myDatabase.ExecuteScalar(myCommand));
}
In my case If I want to change parameter to be strongly typed dataset
as shown in my second method, do I need to move my strongly typed
dataset to DataAccess Layer or it should be separated in another
layer? What I am thinking I may put my strongly typed dataset in
another layer called Business Entity because the strongly typed needs
to share with DataAccess, Business and UI (binding control) as well.
I am not sure it's right or wrong and I don't really know how other
people do it, any suggestion will be really appreciated.
Regards,
Kittipong