当前位置:编程学习 > C#/ASP.NET >>

想使用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 userConnectionOptions) +610
   System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, DbConnectionPoolKey poolKey, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection, DbConnectionOptions userOptions) +1049
   System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnectionPool pool, DbConnectionOptions options, DbConnectionPoolKey poolKey, DbConnectionOptions userOptions) +74
   System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnectionOptions userOptions) +6707883
   System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnectionOptions userOptions) +78
   System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, UInt32 waitForMultipleObjectsTimeout, Boolean allowCreate, Boolean onlyOneCheckConnection, DbConnectionOptions userOptions, DbConnectionInternal& connection) +2192
   System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal& connection) +116
   System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal& connection) +1012
   System.Data.ProviderBase.DbConnectionClosed.TryOpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions) +6712511
   System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource`1 retry) +152
   System.Data.SqlClient.SqlConnection.Open() +229
   System.Data.Linq.SqlClient.SqlConnectionManager.UseConnection(IConnectionUser user) +65
   System.Data.Linq.SqlClient.SqlProvider.get_IsSqlCe() +38
   System.Data.Linq.SqlClient.SqlProvider.InitializeProviderMode() +30
   System.Data.Linq.SqlClient.SqlProvider.System.Data.Linq.Provider.IProvider.Execute(Expression query) +81
   V2.PaidTimeOffDAL.HRPaidTimeOffDataContext.ENTUserAccountSelectAll() in d:\Work\ASP.NET\Enterprise Application Development\PaidTimeOffSolution\V2.PaidTimeOffDAL\HRPaidTimeOff.designer.cs:108
   _Default.btnSelect_Click(Object sender, EventArgs e) in d:\Work\ASP.NET\Enterprise Application Development\PaidTimeOffSolution\PaidTimeOffUI\Default.aspx.cs:85
   System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +155
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3804



最后的是我在拖入后选择否之后这个连接字符串貌似内容还是VS的数据库,我给改了,因为以前点是,连接都存入了dbml文件吧好像。不知道点否之后应该在哪儿写密码啊,
先谢谢大家 --------------------编程问答-------------------- 原生的ADO.NET可以连接吗? --------------------编程问答-------------------- 自己分析一下数据库连接,看是不是加密了 --------------------编程问答-------------------- <connectionStrings>
    <add name="HRPaidTimeOffConnString" connectionString="Data Source=LIUZESEN;Initial Catalog=HRPaidTimeOff;User=sa;PWD=11111111;Max Pool Size=150;Connect Timeout=5000;" providerName="System.Data.SqlClient"/>
  </connectionStrings>


<connectionStrings>
<add name="HRPaidTimeOffConnString" connectionString="Data Source=LIUZESEN;AttachDbFilename=|DataDirectory|\Northwind.mdf;Integrated Security=True;User Instance=True" providerName="System.Data.SqlClient"/>
</connectionStrings> --------------------编程问答-------------------- server=.;uid=sa;pwd=11111111;database=HRPaidTimeOff;

如果不行,就看看就重新改一下sa的密码 --------------------编程问答--------------------
引用 1 楼 licai1210 的回复:
原生的ADO.NET可以连接吗?

您说的是拖入后点是,让LINQ自己连接么,可以的,网站一直可以运行,自从从新拖入后点了否,没有明文保存密码,使用了web.config后才这样 --------------------编程问答--------------------
引用 2 楼 myhope88 的回复:
自己分析一下数据库连接,看是不是加密了

连接在哪儿阿……是不是web.config?里面那个连接字符串本来连的貌似是express,我给改了…… --------------------编程问答--------------------
引用 4 楼 liuchaolin 的回复:
server=.;uid=sa;pwd=11111111;database=HRPaidTimeOff;

如果不行,就看看就重新改一下sa的密码

这个是改过后的密码……如果让linq自己连接,就是把表拖入的时候选择Windows身份验证后者让他明文保存密码都可以连接
补充:.NET技术 ,  ASP.NET
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,