I'm making a login/register SQL Server system and when i made a string to connect i have this problem. My database name is Vartotojai
here is the code
public static DataTable ExecSP(string spname, List<SqlParameter> sqlParams = null)
{
string strConnect = "Server=DESKTOP-MR4OJCU\\MSSQLSERVER01;Database=Vartotojai;Trusted_Connection=True";
SqlConnection conn = new SqlConnection();
DataTable dt = new DataTable();
try
{
//Connect to the DT.
conn = new SqlConnection(strConnect);
conn.Open();
//Build an sql command / query
SqlCommand cmd = new SqlCommand(spname);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddRange(sqlParams.ToArray());
//Execute
SqlCommand command = conn.CreateCommand();
SqlDataReader dr = cmd.ExecuteReader();
//fill dt with results
dt.Load(dr);
}
catch (Exception ex)
{
throw ex;
}
finally
{
//ner skirtumo kas pasaidare isijungs
conn.Close();
}
return dt;
}
}
}
System.Data.SqlClient.SqlException: 'Cannot open database "Vartotojai" requested by the login. The login failed.
Login failed for user 'DESKTOP-MR4OJCU\interkodas'.'
