應用我開發在asp.net應用程序,並遇到了以下問題:用戶登錄失敗在ASP.NET
protected void Button1_Click(object sender, EventArgs e)
{
try
{
string connString = "Data Source = JOHN-4E29FADEE; database=PEOPLE;";
SqlConnection conn = new SqlConnection(connString);
conn.Open();
Response.Write("Succes");
SqlCommand comanda = new SqlCommand();
comanda.Connection = conn;
comanda.CommandType = System.Data.CommandType.Text;
comanda.CommandText = "Select PERSON_ID,FIRST_NAME,FATHER_INITIALS, LAST_NAME, BIRTHDATE,CNP,MOTHER_CNP,FATHER_CNP from PERSON order by FIRST_NAME";
SqlDataReader dr = comanda.ExecuteReader();
GridView4.DataSource = dr;
GridView4.DataBind();
conn.Close();
}
catch (SqlException exc)
{
Response.Write("Connection Error! " + exc.Message);
}
}
當我啓動應用程序時,我得到Connection Error! Login failed for user
。
我連接到SQL Server使用Windows身份驗證和我不在我安裝SQL Server 2008時,請記得爲SQL Server身份驗證設置用戶名和密碼。我應該在這種情況下執行什麼操作? –
你必須使用你的Windows憑證。用戶名和密碼您提供登錄 –
我提供的憑據,但唯一的變化是,連接錯誤!用戶John登錄失敗。 –