Don't share the connection and command objects. As a best practice, create connection, commands when needed, dispose it ones you done with it. check below code.
public class DBoperations
{
public const string CONNECTION_STRING = "Data Source=.;Initial Catalog=Micro;Integrated Security=True";
public DBoperations()
{
}
public static DataTable display1(Creation obj)
{
using (SqlConnection con = new SqlConnection(CONNECTION_STRING))
using (SqlCommand cmd = new SqlCommand("SP_SelectCatgory", con))
{
cmd.CommandType = CommandType.StoredProcedure;
cmd.CommandText = "SP_SelectCatgory";
con.Open();
DataTable dt = new DataTable();
using (SqlDataAdapter sda = new SqlDataAdapter(cmd))
{
sda.Fill(dt);
con.Close();
return dt;
}
}
}
public static int DELETECREATION(Creation obj)
{
using (SqlConnection con = new SqlConnection(CONNECTION_STRING))
using (SqlCommand cmd = new SqlCommand("SP_DeleteCategory", con))
{
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@pdtid", obj.ProductId);
con.Open();
int res = cmd.ExecuteNonQuery();
return res;
}
}
}
then you can call above methods as
DBoperations.display1(obj);
DBoperations.DELETECREATION(obj);
note that you have not following any naming conventions. try to follow coding standards.