Hi i am trying to connect to database with following code. But i am getting an error message saying
Cannot open database "CPL" requested by the login. The login failed. Login failed for user 'Dell-PC\Dell'.
It was working fine before.
C# Code
protected void Page_Load(object sender, EventArgs e)
{
string CurrentDate = DateTime.Today.ToShortDateString();
string CS = ConfigurationManager.ConnectionStrings["ApplicationServices"].ConnectionString;
using (SqlConnection con = new SqlConnection(CS))
{
DataTable dtMatchDetails = new DataTable();
string query = "Select MatchTeam1,MatchTeam2 from tblSchedule Where MatchDate =" + CurrentDate;
SqlCommand cmd = new SqlCommand(query, con);
con.Open();
SqlDataAdapter da = new SqlDataAdapter(cmd);
da.Fill(dtMatchDetails);
con.Close();
da.Dispose();
}
Connection String in Web.Config
<connectionStrings>
<add name="ApplicationServices"
connectionString="data source=.\SQLEXPRESS;Integrated Security=SSPI;User Instance=true;database = CPL"
providerName="System.Data.SqlClient=" />
</connectionStrings>