Как исправить ошибку connectionstring свойство не было инициализировано
После публикации моего сайта я пытаюсь войти в приложение. После входа в систему я получаю ошибку ConnectionString property has not been initialized.
Что я уже пробовал:
public partial class ComplainantLogin : System.Web.UI.Page { private static string CS = ConfigurationManager.ConnectionStrings["E-Docket1ConnectionString"].ConnectionString; private DataTable dt;
protected void LogIn(object sender, EventArgs e) { using (SqlConnection con = new SqlConnection(CS)) using (SqlCommand cmd = new SqlCommand("SELECT * FROM [COMPLAINANT] WHERE ComplainantID='" + txtIDNum.Text + "' AND Password='" + txtPassword.Text + "'", con)) { con.Open(); SqlDataAdapter sda = new SqlDataAdapter(cmd); dt = new DataTable(); sda.Fill(dt); if (dt.Rows.Count != 0)//if supplied ID is found { //Response.Redirect("Default.aspx"); string display = "Message Pop-up!"; ScriptManager.RegisterStartupScript(this, GetType(), "ServerControlScript", display, true); string id = txtIDNum.Text; Session["IDNumber"] = id; Response.Redirect("/ComplainantHomePage.aspx"); Page.ClientScript.RegisterStartupScript(GetType(), "msgbox", "alert('Officer ID found');", true); } else { Page.ClientScript.RegisterStartupScript(GetType(), "msgbox", "alert('Officer ID not found');", true); } } }
и в моем web.config
<add name="E-Docket1ConnectionString" connectionString="Data Source=SQL7001.myWindowsHosting.com;Initial Catalog=DB_A2C4A1_EDocket; providerName="System.Data.SqlClient" /> </connectionStrings>