0

エンタープライズ ライブラリ 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();
        }
    }

次に試すことができるアイデアはありますか?

4

1 に答える 1

0

問題の解決策が見つかりました:)

<恥ずかしそうに頭を垂れる>

リンク サーバーを使用しているストアド プロシージャにテーブルがありましたが、リンク サーバーの正しい偽装をセットアップすると、人生は再び良好になりました。

于 2011-03-10T14:06:25.063 に答える