首页 新闻 会员 周边

asp.net 上传服务器后,MSSQL数据库连接问题

0
悬赏园豆:5 [已解决问题] 解决于 2010-11-27 14:57

我将代码上传到租的空间里,关于mssql连接语句如何写,我是这样

<add name="LocalSqlServer" connectionString="Data Source=.;Initial Catalog=DBTest;User ID=test;Password=test" providerName="System.Data.SqlClient"/>

不知道登录时,提示

Server Error in '/' Application.
--------------------------------------------------------------------------------

用户
'test' 登录失败。
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace
for more information about the error and where it originated in the code.

Exception Details: System.Data.SqlClient.SqlException: 用户
'test' 登录失败。

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified
using the exception stack trace below.

Stack Trace:


[SqlException (
0x80131904): 用户 'test' 登录失败。]
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
AuditingDAL.DBHelper.BuildCmd(String sql, SqlParameter[] sqlParms)
in D:\doudo_Mamager\Auditing\AuditingDAL\DBHelper.cs:58
AuditingDAL.DBHelper.GetDateSet2(String sql, SqlParameter[] values)
in D:\doudo_Mamager\Auditing\AuditingDAL\DBHelper.cs:266
AuditingDAL.UsersService.GetNowData(String strWhere)
in D:\doudo_Mamager\Auditing\AuditingDAL\UsersService.cs:27
AuditingBLL.UsersManager.GetNowData(String strWhere)
in D:\doudo_Mamager\Auditing\AuditingBLL\UsersManager.cs:18
index.btnImg_Click(Object sender, ImageClickEventArgs e)
+977
System.Web.UI.WebControls.ImageButton.OnClick(ImageClickEventArgs e)
+86
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)
+1746

 注:我数据库里没添加test用户,不知道是否跟这个有关

555[]的主页 555[] | 初学一级 | 园豆:4
提问于:2010-11-15 10:26
< >
分享
最佳答案
0

你这个连接串是sql express的写法。服务器不大可能是这样,

看标准的连接串

http://www.connectionstrings.com/sql-server-2005

http://www.connectionstrings.com/sql-server-2008

收获园豆:5
邀月 | 高人七级 |园豆:25475 | 2010-11-15 14:04
其他回答(4)
0

应该是这个问题吧,不知道为什么,你的第一个代码框很小,我这都看不到,看第二个报错的问题,应该是账户不存在,或者是登录不成功的问题。

宪华 | 园豆:0 (初学一级) | 2010-11-15 11:18
0

首先你要确认你买的虚拟空间有没有支持MSSQL,如果有,那一般都会提供一个MSSQL的用户名和密码给你,你对应的连接字符串也应该使用提供给你的账户,当然,数据库名称可能也会跟你本地不一样.

I,Robot | 园豆:9783 (大侠五级) | 2010-11-15 12:00
0

连接字符串那边User ID="test"  改成uid=“Text"  pwd= 试试 吧

 或者看看是不是数据库的用户名密码错了

菜鸟老了 | 园豆:145 (初学一级) | 2010-11-15 17:32
0

<add name="LocalSqlServer" connectionString="Data Source=.;Initial Catalog=DBTest;User ID=test;Password=test" providerName="System.Data.SqlClient"/>

如果数据库服务器和web服务器是一台,且数据库名字是DBTest,登录和密码都正确的话,你这样应该是没有问题的。

清海扬波 | 园豆:825 (小虾三级) | 2010-11-27 17:59
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册