簡體   English   中英

用戶的企業庫5登錄失敗

[英]Enterprise library 5 login failed for user

我剛剛開始使用企業庫5數據訪問應用程序塊,但是我不斷遇到登錄失敗的錯誤。

我嘗試了沒有應用程序塊的情況下使用的連接字符串,並且連接打開正常,但是一旦我將相同的連接字符串與應用程序塊一起使用,它就會失敗。

我的利用DAAB的代碼如下:


public List<AgentInfo> GetAgents()
    {
        Database db = EnterpriseLibraryContainer.Current.GetInstance<Database>("LBDashData");

        string sql = "Users_GetUsers";
        DbCommand cmd = db.GetStoredProcCommand(sql);

        List<AgentInfo> oAgents = new List<AgentInfo>();

        using (IDataReader dataReader = db.ExecuteReader(cmd))
        {
            while (dataReader.Read())
            {
                AgentInfo oAgent = new AgentInfo();

                oAgent.ItemID = Convert.ToInt32( dataReader["ItemID"].ToString());
                oAgent.ParentID = Convert.ToInt32(dataReader["ParentID"].ToString());
                oAgent.TeamID = Convert.ToInt32(dataReader["TeamID"].ToString());
                oAgent.Team = dataReader["Team"].ToString();
                oAgent.AgentName = dataReader["AgentName"].ToString();
                oAgent.NodeType = dataReader["NodeType"].ToString();

                oAgents.Add(oAgent);
            }
        }

        return oAgents;
    }

我在配置中的連接字符串已設置如下:


<connectionStrings><add name="LBDashData" connectionString="Data Source=(local);Initial Catalog=LBDash;Persist Security Info=True;User id=<userid>;password=<password>" <providerName="System.Data.SqlClient" /></connectionStrings>

如果我嘗試使用以下代碼使用相同的連接字符串,則可以正常工作

        public bool testConn ()
    {
        SqlConnection oconn = new SqlConnection("Data Source=(local);Initial Catalog=LBDash;Persist Security Info=True;User id=<userid>;password=<password>");

        try
        {
            oconn.Open();
            return true;
        }
        catch
        {
            return false;
        }
        finally
        {
            oconn.Close();
        }
    }

有誰知道我接下來可以嘗試什么?

找到問題的解決方案:)

< 垂頭喪氣 >

我在存儲過程中有使用鏈接服務器的表,一旦為鏈接服務器設置了正確的模擬,生活就再好不過了。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM