我已经花了数小时寻找这个问题的答案...我以前访问ASPNETDB数据库时不会出现这个错误,但不幸的是我不知道我改了什么。当我尝试访问一个名为Admin.aspx的文件时,错误就会出现,而我将其放在一个名为Admin的文件夹中。我使用Web站点管理工具对此文件夹设置了限制,但当错误出现时,我将所有限制都取消了,以查看问题所在,但我仍然遇到了错误?只有Admin.aspx文件会出错..
我的web.config中的连接字符串是:
我的web.config中的连接字符串是:
<add name="WIJLConnectionString1" connectionString="Data Source=localhost;Integrated Security=SSPI; Initial Catalog=ASPNETDB" providerName="System.Data.SqlClient" />
以下是错误信息:
异常细节: System.Data.SqlClient.SqlException:无法打开请求的数据库“ASPNETDB”,登录失败。用户“Philip-Desktop\Philip”登录失败。 [SqlException(0x80131904):无法打开请求的数据库“ASPNETDB”,登录失败。用户“Philip-Desktop\Philip”登录失败。] System.Data.SqlClient.SqlInternalConnection.OnError(SqlException异常,Boolean breakConnection)+5009598 System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning()+234 System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior,SqlCommand cmdHandler,SqlDataReader dataStream,BulkCopySimpleResultSet bulkCopyHandler,TdsParserStateObject stateObj)+2275 System.Data.SqlClient.SqlInternalConnectionTds.CompleteLogin(Boolean enlistOK)+35 System.Data.SqlClient.SqlInternalConnectionTds.AttemptOneLogin(ServerInfo serverInfo,String newPassword,Boolean ignoreSniOpenTimeout,TimeoutTimer timeout,SqlConnection owningObject)+183 System.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover(ServerInfo serverInfo,String newPassword,Boolean redirectedUserInstance,SqlConnection owningObject,SqlConnectionString connectionOptions,TimeoutTimer timeout)+239 System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(SqlConnection owningObject,TimeoutTimer timeout,SqlConnectionString connectionOptions,String newPassword,Boolean redirectedUserInstance)+195 System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity,SqlConnectionString connectionOptions,Object providerInfo,String newPassword,SqlConnection owningObject,Boolean redirectedUserInstance)+232 System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options,Object poolGroupProviderInfo,DbConnectionPool pool,DbConnection owningConnection)+185 System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnection owningConnection,DbConnectionPool pool,DbConnectionOptions options)+33 System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject)+524 System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject)+66 System.Data.ProviderBase.DbConnectionPool.GetConnection(DbConnection owningObject)+479 System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection)+108 System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection,DbConnectionFactory connectionFactory)+126 System.Data.SqlClient.SqlConnection.Open()+125 System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset,DataTable [] datatables,Int32 startRecord,Int32 maxRecords,String srcTable,IDbCommand command,CommandBehavior behavior)+123 System.Data.Common.DbDataAdapter.Fill(DataSet dataSet,Int32 startRecord,Int32 maxRecords,String srcTable,IDbCommand command,CommandBehavior behavior)+319 System.Data.Common.DbDataAdapter.Fill(DataSet dataSet,String srcTable)+92 System.Web.UI.WebControls.SqlDataSourceView.ExecuteSelect(DataSourceSelectArguments arguments)+1618 System.Web.UI.DataSourceView.Select(DataSourceSelectArguments arguments,DataSourceViewSelectCallback callback)+21 System.Web.UI.WebControls.DataBoundControl.PerformSelect()+143 System.Web.UI.WebControls.BaseDataBoundControl.DataBind()+74 System.Web.UI.WebControls.GridView.DataBind()+4 System.Web.UI.WebControls.BaseDataBoundControl.EnsureDataBound()+66 System.Web.UI.WebControls.CompositeDataBoundControl.CreateChildControls()+75 System.Web.UI.Control.EnsureChildControls()+102 System.Web.UI.Control.PreRenderRecursiveInternal()+42 System.Web.UI.Control.PreRenderRecursiveInternal()+175 System.Web.UI.Control.PreRenderRecursiveInternal()+175 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint,Boolean includeStagesAfterAsyncPoint)+2496有人能帮忙吗!!我现在非常绝望
localhost
、(local)
和.
应该是等效的;问题是:你的SQL Server是否安装为主/默认实例而没有单独的实例名称,或者你安装了例如Express,默认为SQLExpress
实例名称(你需要将其添加到服务器名称中才能连接)。 - marc_s