using System;
using System.Data.SqlClient;
using System.Data;
namespace DataAccess
{
/// <summary>
/// It is used to asscess database
/// </summary>
public class Database:IDisposable
{
/// <summary>
/// It's store the error message
/// </summary>
string _errorMessage;
/// <summary>
///It's store the Exception
/// </summary>
System.Exception _exception;
/// <summary>
/// It is marked run state.
/// </summary>
int result;
/// <summary>
/// store Connection String
/// </summary>
//string _connectionString;
SqlConnection myConnection;
SqlCommand myCommand;
string _ConfigurationConnectionString=null;
#region IDisposable 成员
public void Dispose()
{
if(this.myConnection==null)
myConnection.Dispose();
else
myConnection=null;
System.GC.SuppressFinalize(this);
}
#endregion
/// <summary>
/// get or set Exception as string .
/// </summary>
///
public string ErrorMessage
{
get{ return _errorMessage;}
set{ _errorMessage=value;}
}
public int Result
{
get{return result;}
}
/// <summary>
/// get or set Exception.
/// </summary>
public Exception Exception
{
get{return _exception;}
set{_exception=value;}
}
/// <summary>
/// Set ConnectionString where in Web.Config
/// </summary>
public string ConfigurationConnectionString
{
get{return this._ConfigurationConnectionString;}
set{this._ConfigurationConnectionString=value;}
}
/// <summary>
/// get Connetion string from web.Config.if you hava not set the ConfigurationConnection.
/// it will get AppSettings by connectionString,if you want set the ConnectionString you
/// can use it.
/// </summary>
private string ConnectionString
{
get{
if(this._ConfigurationConnectionString==null)
{
return (string)System.Configuration.ConfigurationSettings.AppSettings["connectionString"];
}
else
{
return (string)this._ConfigurationConnectionString;