我有一个连接到 SQL Server 数据库的简单控制台应用程序。但是,它在运行时会引发以下错误。有什么线索吗?
Unhandled Exception: System.Data.SqlClient.SqlException: Cannot open database "Database" requested by the login. The login failed.
Login failed for user 'MYDOMAIN\MYUSERID'.
   at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection)
   at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj)
   at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj)
   at System.Data.SqlClient.SqlInternalConnectionTds.CompleteLogin(Boolean enlistOK)
   at System.Data.SqlClient.SqlInternalConnectionTds.AttemptOneLogin(ServerInfo serverInfo, String newPassword, BooleanignoreSniOpenTimeout, Int64 timerExpire, SqlConnection owningObject)
   at System.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover(String host, String newPassword, Boolean redirectedUserInstance, SqlConnection owningObject, SqlConnectionString connectionOptions, Int64 timerStart)
我使用 SQL Server 2005 速成版。但是,我可以使用数据库资源管理器从 Visual Web 开发人员连接到 SQL Server。我使用的代码如下:
using System;
using System.Data;
using System.Data.SqlClient;
    public class Test
    {
        public Test()
        {
        }
        static void Main()
        {
            Console.WriteLine("hello");
            string connectionString = "Data Source=localhost\\SQLEXPRESS;Database=Database;Integrated Security=true";
            SqlConnection conn = new SqlConnection(connectionString);
            conn.Open();
            Console.WriteLine("done");
        }
    }