View Single Post
  #6 (permalink)  
Old July 22nd, 2008, 08:12 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
Default

It makes perfect sense to make the class partially static. However, you then need to pass user data directly in a method. For example:

public static DataSet GetDataSet(string sql)
{
  // Create *new* SqlConnection
  // Execute connection
  // return DataSet.
}

This way, the method is easy to use:

DataSet myDataSet = DataAccess.GetDataSet("SELECT Id, Name FROM table");

However, since inside the method a new connection is created, opened and closed, each user can work with their own data and queries.

Hope this helps,

Imar

---------------------------------------
Imar Spaanjaars
http://Imar.Spaanjaars.Com
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