i have a problem with my Connection String , i have an Execute method with string parameter to Receive queries ,
public class Create_Connection
{
public static readonly string CONN_STRING =
ConfigurationManager.ConnectionStrings["TaskConnectionString"].ConnectionString;
public static readonly SqlConnection SqlConn = new SqlConnection(CONN_STRING);
public static readonly SqlConnection CONN = new SqlConnection(CONN_STRING);
public DataSet ExecuteSql(string sql)
{
SqlDataAdapter da;
DataSet ds;
if (CONN.State == ConnectionState.Open)
CONN.Close();
CONN.Open();
da = new SqlDataAdapter(sql, CONN_STRING);
ds = new DataSet();
da.Fill(ds);
CONN.Dispose();
CONN.Close();
return ds;
}
}
when i use it first time it's work will , but when the time of second query comes to use Execute method my program stop and give me this masseg : "The ConnectionString property has not been initialized" !! and the InnerException : " null " !!!
how that possible when it's work in the first time then change when the Conniction String is " Static readonly " !!
and Thanks in advance :) ..