首页上一页 1 下一页尾页 3 条记录 1/1页
异常详细信息: System.Data.SqlClient.SqlException: 用户 'sa' 登录失败。??????
发表在ASP.NET图书答疑
2011-05-16
是否精华
是
否
版块置顶:
是
否
初学ASP.NET编程宝典(C#)例8.3 数据库连接时,
我是首先将db_08数据库复制到App_Data文件夹中,然后在SQL2005数据库通过数据库附加将db_08添加到本机及计算机名称为PC-201009111555的服务器的数据库中,
然后将在所建公共类中将连接字符串更改为了:
conStr = "server=PC-201009111555;DataBase=db_08;uid=sa;pwd=;";
在游览器中查看时确出现了下列的问题???
行 30: conn.Open(); //打开数据库连接
中的 Open();出现了问题?
请教高手们,该如何修改????
我也不知道什么原因?在学习你们提供的《C#开发实战宝典》时,也是出现按书中的相关要求,无论怎样折腾,就像现在学习《ASP.NET编程宝典》一样,老是连接不上拟定的数据库??????
请回复时不要重复地说 conStr = "server=PC-201009111555;DataBase=db_08;uid=sa;pwd=;"; 这个地方是否写错!!!!! 这个地方肯定是没有写错? 请提出能解放问题的回复!!!
“/例8.3”应用程序中的服务器错误。
________________________________________
用户 'sa' 登录失败。
说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。
异常详细信息: System.Data.SqlClient.SqlException: 用户 'sa' 登录失败。
源错误:
行 28: {
行 29: conn = new SqlConnection(conStr); //不存在,新建数据库连接
行 30: conn.Open(); //打开数据库连接
行 31: }
行 32: else
源文件: f:\8\例8.3\App_Code\OperateDataBase.cs 行: 30
堆栈跟踪:
[SqlException (0x80131904): 用户 'sa' 登录失败。]
System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) +821651
System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj) +186
System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj) +1932
System.Data.SqlClient.SqlInternalConnectionTds.CompleteLogin(Boolean enlistOK) +33
System.Data.SqlClient.SqlInternalConnectionTds.AttemptOneLogin(ServerInfo serverInfo, String newPassword, Boolean ignoreSniOpenTimeout, Int64 timerExpire, SqlConnection owningObject) +172
System.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover(String host, String newPassword, Boolean redirectedUserInstance, SqlConnection owningObject, SqlConnectionString connectionOptions, Int64 timerStart) +381
System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(SqlConnection owningObject, SqlConnectionString connectionOptions, String newPassword, Boolean redirectedUserInstance) +181
System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, Object providerInfo, String newPassword, SqlConnection owningObject, Boolean redirectedUserInstance) +173
System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection) +357
System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnection owningConnection, DbConnectionPool pool, DbConnectionOptions options) +30
System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject) +424
System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject) +66
System.Data.ProviderBase.DbConnectionPool.GetConnection(DbConnection owningObject) +494
System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection) +82
System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory) +105
System.Data.SqlClient.SqlConnection.Open() +111
OperateDataBase.Open() in f:\8\例8.3\App_Code\OperateDataBase.cs:30
OperateDataBase.checkLogin(String loginName, String loginPwd) in f:\8\例8.3\App_Code\OperateDataBase.cs:111
_Default.imgBtnLogin_Click(Object sender, ImageClickEventArgs e) in f:\8\例8.3\Default.aspx.cs:25
System.Web.UI.WebControls.ImageButton.OnClick(ImageClickEventArgs e) +105
System.Web.UI.WebControls.ImageButton.RaisePostBackEvent(String eventArgument) +115
System.Web.UI.WebControls.ImageButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +7
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +11
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +5087
________________________________________
版本信息: Microsoft .NET Framework 版本:2.0.50727.1882; ASP.NET 版本:2.0.50727.187
我是首先将db_08数据库复制到App_Data文件夹中,然后在SQL2005数据库通过数据库附加将db_08添加到本机及计算机名称为PC-201009111555的服务器的数据库中,
然后将在所建公共类中将连接字符串更改为了:
conStr = "server=PC-201009111555;DataBase=db_08;uid=sa;pwd=;";
在游览器中查看时确出现了下列的问题???
行 30: conn.Open(); //打开数据库连接
中的 Open();出现了问题?
请教高手们,该如何修改????
我也不知道什么原因?在学习你们提供的《C#开发实战宝典》时,也是出现按书中的相关要求,无论怎样折腾,就像现在学习《ASP.NET编程宝典》一样,老是连接不上拟定的数据库??????
请回复时不要重复地说 conStr = "server=PC-201009111555;DataBase=db_08;uid=sa;pwd=;"; 这个地方是否写错!!!!! 这个地方肯定是没有写错? 请提出能解放问题的回复!!!
“/例8.3”应用程序中的服务器错误。
________________________________________
用户 'sa' 登录失败。
说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。
异常详细信息: System.Data.SqlClient.SqlException: 用户 'sa' 登录失败。
源错误:
行 28: {
行 29: conn = new SqlConnection(conStr); //不存在,新建数据库连接
行 30: conn.Open(); //打开数据库连接
行 31: }
行 32: else
源文件: f:\8\例8.3\App_Code\OperateDataBase.cs 行: 30
堆栈跟踪:
[SqlException (0x80131904): 用户 'sa' 登录失败。]
System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) +821651
System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj) +186
System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj) +1932
System.Data.SqlClient.SqlInternalConnectionTds.CompleteLogin(Boolean enlistOK) +33
System.Data.SqlClient.SqlInternalConnectionTds.AttemptOneLogin(ServerInfo serverInfo, String newPassword, Boolean ignoreSniOpenTimeout, Int64 timerExpire, SqlConnection owningObject) +172
System.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover(String host, String newPassword, Boolean redirectedUserInstance, SqlConnection owningObject, SqlConnectionString connectionOptions, Int64 timerStart) +381
System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(SqlConnection owningObject, SqlConnectionString connectionOptions, String newPassword, Boolean redirectedUserInstance) +181
System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, Object providerInfo, String newPassword, SqlConnection owningObject, Boolean redirectedUserInstance) +173
System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection) +357
System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnection owningConnection, DbConnectionPool pool, DbConnectionOptions options) +30
System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject) +424
System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject) +66
System.Data.ProviderBase.DbConnectionPool.GetConnection(DbConnection owningObject) +494
System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection) +82
System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory) +105
System.Data.SqlClient.SqlConnection.Open() +111
OperateDataBase.Open() in f:\8\例8.3\App_Code\OperateDataBase.cs:30
OperateDataBase.checkLogin(String loginName, String loginPwd) in f:\8\例8.3\App_Code\OperateDataBase.cs:111
_Default.imgBtnLogin_Click(Object sender, ImageClickEventArgs e) in f:\8\例8.3\Default.aspx.cs:25
System.Web.UI.WebControls.ImageButton.OnClick(ImageClickEventArgs e) +105
System.Web.UI.WebControls.ImageButton.RaisePostBackEvent(String eventArgument) +115
System.Web.UI.WebControls.ImageButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +7
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +11
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +5087
________________________________________
版本信息: Microsoft .NET Framework 版本:2.0.50727.1882; ASP.NET 版本:2.0.50727.187