【问题标题】:Cannot Assign to "GetconnectionInfo" Because it is a group Method无法分配给“GetconnectionInfo”,因为它是一个组方法
【发布时间】:2019-05-07 05:29:04
【问题描述】:
I am facing the error at "GetConnectionInfo"
Private string GetConnectionInfo(string ConName)
        {
            string PKey;
            PKey = GetKeyInfo();
            System.Data.OleDb.OleDbDataReader rs;
            System.Data.OleDb.OleDbConnection oCon = new System.Data.OleDb.OleDbConnection();
            System.Data.OleDb.OleDbCommand oComm = new System.Data.OleDb.OleDbCommand();
            string sSql;
            string ConfConnection;
            try
            {
                ConfConnection = Dts.Connections("Config").ConnectionString.ToString();
               oCon.ConnectionString = ConfConnection;
                oCon.Open();
                sSql = "SELECT [CNCTN_NM],[USER_ID],[PSWRD_TXT],[DATA_SRC_NM],[CATLG_NM],[PRVDR_NM], [INTEGRATED_SECURITY] FROM [TDW_ETL_CONNECTSTRING] WHERE [CNCTN_NM] = '" + ConName + "'";
                oComm.CommandText = sSql;
                oComm.Connection = oCon;
                oComm.CommandTimeout = 600;
                rs = oComm.ExecuteReader();
                string CNCTN_NM;
                string USER_ID;
                string PSWRD_TXT;
                string dUSER_ID;
                string dPSWRD_TXT;
                string DATA_SRC_NM;
                string CATLG_NM;
                string PRVDR_NM;
                bool INTEGRATED_SECURITY;
                while (rs.Read())
                {
                    // Get The Data from the table
                    CNCTN_NM = System.Convert.ToString(rs.GetValue(0));
                    if (rs.IsDBNull(1) == false)
                        USER_ID = System.Convert.ToString(rs.GetValue(1));

                    if (rs.IsDBNull(2) == false)
                        PSWRD_TXT = System.Convert.ToString(rs.GetValue(2));

                    DATA_SRC_NM = System.Convert.ToString(rs.GetValue(3));
                    CATLG_NM = System.Convert.ToString(rs.GetValue(4));
                    PRVDR_NM = System.Convert.ToString(rs.GetValue(5));
                    INTEGRATED_SECURITY = System.Convert.ToBoolean(rs.GetBoolean(6));

                    // Decrypt the userid and password
                    if (INTEGRATED_SECURITY == false)
                    {
                        dUSER_ID = DecryptTripleDES(USER_ID, PKey);
                        dPSWRD_TXT = DecryptTripleDES(PSWRD_TXT, PKey);
                    }
                }

这里我收到错误 ====>

GetConnectionInfo = GenerateConnectionString(PRVDR_NM, dUSER_ID, dPSWRD_TXT, INTEGRATED_SECURITY, DATA_SRC_NM, CATLG_NM);
                }
                finally
                {
                    if (!rs.IsClosed)
                        rs.Close();
                    oComm.Dispose();
                    oCon.Dispose();
                }
            }

【问题讨论】:

  • 这也是代码的一部分,在这里我得到了错误====> GetConnectionInfo = GenerateConnectionString(PRVDR_NM, dUSER_ID, dPSWRD_TXT, INTEGRATED_SECURITY, DATA_SRC_NM, CATLG_NM); } 最后 { if (!rs.IsClosed) rs.Close(); oComm.Dispose(); oCon.Dispose(); } }
  • 最初这段代码是用 vb.net 编写的并且工作正常,一旦我在 c# 中转换了这段代码,我在 GetConnectionInfo = GenerateConnectionString(PRVDR_NM, dUSER_ID, dPSWRD_TXT, INTEGRATED_SECURITY, DATA_SRC_NM, CATLG_NM) 处遇到错误;

标签: c# asp.net asp.net-mvc c#-4.0


【解决方案1】:

您正在尝试为方法分配值。这是不可能的。 我认为您想要达到的目标可能是:

string connectionInfo = GetConnectionInfo(GenerateConnectionString(PRVDR_NM, dUSER_ID, dPSWRD_TXT, INTEGRATED_SECURITY, DATA_SRC_NM, CATLG_NM));

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-12-25
    • 2014-11-27
    • 1970-01-01
    • 2013-11-15
    • 2017-02-16
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多