hi, i am trying to build a connection string in web config but still connection is not build.
Error
Non-invocable member 'System.Configuration.ConfigurationManager.ConnectionStrings' cannot be used like a method
<connectionStrings>
<add name="hotelManagement" connectionString="server = LENOVO-PC\himani;database=hotel_management;Integrated Security=True;User Instance=True"></add>
</connectionStrings>
public partial class _Default : System.Web.UI.Page
{
protected void btnSubmit_Click(object sender, EventArgs e)
{
string username = txtUserName.Text;
string password = txtPassword.Text;
//string cs = "data source = ,;database=hotel_management;";
string cmg = ConfigurationManager.ConnectionStrings("hotelManagement").ConnectionString;
SqlConnection cnn = new SqlConnection(cmg);
cnn.Open();
string query = "sp_insertdata";
SqlCommand cmd = new SqlCommand(query,cnn);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("username",username);
cmd.Parameters.AddWithValue("password",password);
cmd.ExecuteNonQuery();
Response.Write("account created successfully");
cnn.Close();
}
}
can you tell me what's wrong with my code.