View Single Post
  #4 (permalink)  
Old July 22nd, 2008, 02:44 AM
Imar's Avatar
Imar Imar is offline
Wrox Author
Points: 72,073, Level: 100
Points: 72,073, Level: 100 Points: 72,073, Level: 100 Points: 72,073, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,587 Times in 1,563 Posts

Again, it would help if you provided more information.....

Where does this code come from? What parts do you and don't you understand? Where do you see possible problems?

AFAICS, it's already working with SQL Server databases, considering the SqlConnection and other classes.

However, IMO, it has a few design flaws. First of all, it uses embedded connection strings. IMO, you should put them in an app.config file.

Secondly, the entire class is static. This will produce great problems.

For example, consider the Query property. This is shared by *all users* of this class. So, one user sets the query, then tries to execute it. However, before the query is executed, a second user overwrites the Query property. This gives the first user the results of the query of the second user. Not really reliable for a data access class... ;)

So, all in all, I don't think this is great code. You may want to pick up a book like Beginning Databases or look at the Microsoft Quick Starts for ADO.NET. For example, look here:
However, this is just an example. Searching Google for Microsoft Quick Starts for ADO.NET should yield many more useful results.

Hope this helps; if you need more information, please ask specific questions. "Please try to improve the code. Keep the core structural concept unchanged." is usually considered an assignment, not a great or useful question.



Imar Spaanjaars
Everyone is unique, except for me.
Author of Beginning ASP.NET 3.5 : in C# and VB, ASP.NET 2.0 Instant Results and Dreamweaver MX 2004
Want to be my colleague? Then check out this post.
Reply With Quote