简体   繁体   English

无法分配给“GetconnectionInfo”因为它是一个组方法

[英]Cannot Assign to “GetconnectionInfo” Because it is a group Method

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);
                    }
                }

Here i am getting the error ====> 在这里我得到错误====>

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();
                }
            }

You are trying to assign a value to a method. 您正在尝试为方法分配值。 That is not possible. 这是不可能的。 I think what you want to achive could be something like: 我认为你想要的东西可能是这样的:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM