/// Summary description for CommonQueryExecution
///
public class CommonQueryExecution
{
public bool flag = false;
public string querry = string.Empty;
private string returnString = string.Empty;
private SqlConnection con = null;
private SqlCommand cmd = null;
private SqlDataAdapter da = null;
private SqlDataReader dr = null;
private string strCon = ConfigurationManager.ConnectionStrings["BDConnectionString"].ToString();
///
/// used to execute all Querry statement.
///
/// param name="data"
///
public DataSet ExecuteQuerry(string data)
{
con = new SqlConnection(strCon);
da = new SqlDataAdapter(data,con);
DataSet ds = new DataSet();
da.Fill(ds);
return ds;
}
///
/// used to execute all non querry statement.
///
/// param name="data"
///
public bool ExecuteNonQuerry(string data)
{
con = new SqlConnection(strCon);
cmd = new SqlCommand(data, con);
if (con.State == ConnectionState.Closed)
{
con.Open();
}
if (cmd.ExecuteNonQuery() > 0)
{
flag = true;
}
else
{
flag = false;
}
if (con.State == ConnectionState.Open)
{
con.Close();
}
return flag;
}
///
///This function is used to check any record is exists or not
///
public bool IsValueExits(string data)
{
con = new SqlConnection(strCon);
cmd = new SqlCommand();
cmd.CommandText = data;
cmd.Connection = con;
if (con.State == ConnectionState.Closed)
{
con.Open();
}
dr = cmd.ExecuteReader();
if (dr.HasRows)
{
flag = true;
}
else
{
flag = false;
}
if (con.State == ConnectionState.Open)
{
con.Close();
}
return flag;
}
}
কোন মন্তব্য নেই:
একটি মন্তব্য পোস্ট করুন