-1
我收到此錯誤信息同時使用數據適配器上的SQL Server Express
無法打開數據庫「股票」的要求登錄處理異常。登錄失敗。 用戶'user-pc \ computer'登錄失敗。
代碼我已經寫:
protected void btnSubmit_Click(object sender, EventArgs e)
{
using (SqlConnection con = new SqlConnection("Data Source=user-pc\\SQLEXPRESS;Initial Catalog=stock; Integrated Security=True;User Instance=True"))
{
using(SqlCommand cmd=new SqlCommand("Select username,password from userprofile where [email protected]",con))
{
cmd.Parameters.AddWithValue("@username", txtUserName.Text);
DataTable dt = new DataTable();
SqlDataAdapter da = new SqlDataAdapter(cmd);
da.Fill(dt);
string userid = dt.Rows[0]["username"].ToString();
它顯示了da.fill(dt)
可能是一大堆事情。您是否可以在代碼之外以該用戶身份連接到該機器上的該實例?以Sql Server Management studio爲例?如果是這樣你能看到數據庫? –
@TonyHopkinson是的,我可以連接通過SQL服務器管理工作室2008-R2 – user1700961
@ user1700961當你連接到SSMS,你連接到'user-pc \ SQLEXPRESS'正確嗎? –