public class FileRight:IDisposable
{
private SqlDataAdapter dsCommand;
public SqlConnection mySqlConnection;
public static string CONN;
public FileRight()
{
CONN=System.Configuration.ConfigurationSettings.AppSettings["ConnectionString"];
mySqlConnection = new SqlConnection(CONN);
}
public void Dispose()
{
Dispose(true);
GC.SuppressFinalize(true);
}
protected virtual void Dispose(bool disposing)
{
if (! disposing)
return;
if (dsCommand != null)
{
if(dsCommand.SelectCommand != null)
{
if( dsCommand.SelectCommand.Connection != null )
dsCommand.SelectCommand.Connection.Dispose();
dsCommand.SelectCommand.Dispose();
}
dsCommand.Dispose();
dsCommand = null;
}
}
......
}