日期:2014-05-17  浏览次数:20547 次

想使用web.config导致网页sa登陆失败
研究了一晚上,实在熬不住了,问题是这样的,看的ASP.NET 3.5商用开发架构精解,里面在教使用LINQ的时候说让试一试将服务器资源管理器里面的表拖入得时候提示是否保存明文密码的时候选择否,在web.config中配置连接字符串,然后我打开网页只要涉及数据库操作都会提示sa登陆失败,
web.config 内容是
 <connectionStrings>
    <add name="HRPaidTimeOffConnString" connectionString="Data Source=LIUZESEN;Initial Catalog=HRPaidTimeOff;Persist Security Info=True;User ID=sa;Password=11111111" providerName="System.Data.SqlClient"/>
  </connectionStrings>

数据库登陆没问题,127.0.0.1,LIUZESESEN,localhost都能连上,混合登陆也开了,
是不是哪儿还没配对,

使用连接字符串的位置貌似是           
using (HRPaidTimeOffDataContext db = new HRPaidTimeOffDataContext(DBHelper.GetHRPaidTimeOffConnectionString()))

DBHelper内容是
        private const string HRPAIDTIMEOFF_CONNSTRING_KEY = "HRPaidTimeOffConnString";

        public static string GetHRPaidTimeOffConnectionString()
        {
            return ConfigurationManager.ConnectionStrings[HRPAIDTIMEOFF_CONNSTRING_KEY].ConnectionString;
        }

网页提示
[SqlException (0x80131904): 用户 'sa' 登录失败。]
   System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction) +6676046
   System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose) +810
   System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady) +4403
   System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj) +84
   System.Data.SqlClient.SqlInternalConnectionTds.CompleteLogin(Boolean enlistOK) +55
   System.Data.SqlClient.SqlInternalConnectionTds.AttemptOneLogin(ServerInfo serverInfo, String newPassword, SecureString newSecurePassword, Boolean ignoreSniOpenTimeout, TimeoutTimer timeout, Boolean withFailover) +368
   System.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover(ServerInfo serverInfo, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString connectionOptions, SqlCredential credential, TimeoutTimer timeout) +6704814
   System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(TimeoutTimer timeout, SqlConnectionString connectionOptions, SqlCredential credential, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance) +6705315
   System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, SqlCredential credential, Object providerInfo, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString