Pages

Wednesday, May 18, 2011

Define Globally Class

public class clsGENERAL

{

    string str = ConfigurationManager.ConnectionStrings["d"].ConnectionString;

    SqlConnection con;

    SqlCommand cmd;

    SqlDataAdapter da;

    DataSet ds = new DataSet();

    public clsGENERAL()

    {

       

    }

    public int FireQuery(string qry)

    {

        con = new SqlConnection(str);

        con.Open();

        cmd = new SqlCommand(qry, con);

        int i = cmd.ExecuteNonQuery();

        con.Close();

        return i;

    }

    public DataSet SelectQuery(string qry)

    {

        con = new SqlConnection(str);

        con.Open();

        ds.Reset();

        da = new SqlDataAdapter(qry, con);

        da.Fill(ds);

        return ds;

    }

}

No comments:

Post a Comment