Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ASP.NET 2.0 DataSource control Vs. Class programming

Status
Not open for further replies.

joggi

Programmer
Nov 8, 2006
44
YU
I have Visual Studio 2005 and I start to read ASP.NET 2.0 tutorials. In all tutorials they say that DataSource control and wizards are much better then writing the code for connections, filling dataset etc… They say:
“While point-and-click data access is useful for prototyping and for beginners or hobbyists who have little to no programming experience, wizards and the like are generally frowned upon by more seasoned developers since they typically offer ease of use at the cost of extensibility and customizability. The ASP.NET 2.0 data source controls, however, provide the best of both worlds, in my opinion - they can be quickly and easily configured to work with data, yet through a myriad of events that are raised during the data source controls' lifecycles, provide the flexibility for use in more advanced scenarios. “
I would like to hear developer’s opinion about this. Should I start with DataSource control or with the old way of programming?
Thanks in advance
 
joggi,

I personally dont use DataSource Controls, call it personal preference, I prefer to write the code to do my data work not only because from the world of old ASP I became accustomed to it and now its 2nd nature, but also because I feel I have more control over whats going on (IMO) with my data and binding.

Senior Qik III, ASP.Net, VB.Net ,SQL Programmer

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
** Do NOT feed Code Gremlins after midnight **
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
I would highly suggest using the ObjectDataSource control and mapping it to a custom Data Class. It provides the developer with a lot more options and really isn't that difficult to accomplish. It also abides by the best practice of separating content from the data.

I build ASP.NET pages interfacing with SQL Server and Oracle and once you get this technique down, it's pretty straightforward. In some cases I have only gotten something to work by using the ObjectDataSource, especially when you are dealing with complex parameters.

Murach's ASP.NET for VB.NET/C# 2005 provides a great chapter on creating data access classes with the ObjectDataSource. I don't think this material is just for the advanced developer.
 

Hey,

Like you said, the wizards are good for creating connection strings. If they are bound to a Control (ie a GridView) and the SQL query is something like "SELECT FROM exampleTable" and you then you later change the number of columns in the exampleTable and forget to refresh the Control schema from the Designer view and recompile the website, it will cause an error.

If you were to program the dataset and bind it to a data control, you can write script to that creates the proper number of columns based on the number of columns retrieved from the dataset.

This sole drawback turned me away from the wizard.
 
Thank you,
In my old VB 6 project I developed some classes with methods for Select, Insert, Update, Delete that works with any table and database. I would like to continue with these classes, and because of that I ask for advice.
 
It works basically the same way for .NET 2.0. For selecting data I usually return a data reader as IEnumberable. In VB6 you would return a Recordset.
 
I find ObjectDataSource programming to be the best approach, especially for resuability and extensibility.

Also, you should check out the Data Abstraction Layer in the best practices Enterprise Library (available as free download from Microsoft site). That is a gem too.

I am also really having fun with the new AJAX components offered at
Sean. [peace]
 
IARESEAN, how do you feel that AJAX has supplemented your .NET development?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top