编辑: SQL 连接已更新。
控制器:
Imports System.Data.SqlClient
Function SQLSelect() As ActionResult
Dim theconnection As New SqlConnection("Data Source=MSSQLSERVER;server=(localdb)\Projects;Database=test_drive_database;User Id=xxxx_user-PC\xxxx_user;password=;Trusted_Connection=True;Integrated Security=True;")
theconnection.Open()
Dim queryString As String = "SELECT * FROM ColorTable"
Dim command As New SqlCommand(queryString)
command.BeginExecuteNonQuery()
command.CommandTimeout = 15
command.CommandType = CommandType.Text
'Printing Out the SQL Result
Return ViewData("command")
End Function
错误消息:
Cannot open database "test_drive_database" requested by the login. The login failed.
Login failed for user 'xxxx_user-PC\xxxx_user'.
如何找出登录失败的确切原因?
注意: 不使用密码。
附录:
Dim theconnection As New SqlConnection("Data Source=MSSQLSERVER;server=(localdb)\Projects;Database=ColorTable_database.sdf;Integrated Security=sspi;")
theconnection.Open()
这也是我尝试过的一种变体,尽管我收到了相同的错误消息。