int userId = 0;
string roles = string.Empty;
string constr = ConfigurationManager.ConnectionStrings["constr"].ConnectionString;
using (SqlConnection con = new SqlConnection(constr))
{
using (SqlCommand cmd = new SqlCommand("Validate_User"))
{
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@Username", Login1.UserName);
cmd.Parameters.AddWithValue("@Password", Login1.Password);
cmd.Connection = con;
con.Open();
in the web.config
, the connection string is defined as
<add name="constr"
connectionString="data source=.;initial catalog=LoginDB;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework"
providerName="System.Data.SqlClient" />
but when I run it, I get an error:
System.Data.SqlClient.SqlException: Cannot open database "LoginDB" requested by the login. The login failed.
Login failed for user 'NT AUTHORITY\SYSTEM'.
Any solutions?