CSDataBase.cDataBase.openRs C# (CSharp) Method

openRs() public method

public openRs ( string sqlstmt, System.Data.Common.DbDataReader &ors, string function, string module, string title, eErrorLevel level ) : bool
sqlstmt string
ors System.Data.Common.DbDataReader
function string
module string
title string
level eErrorLevel
return bool
        public bool openRs(string sqlstmt,
                           out DbDataReader ors,
                           string function,
                           string module,
                           string title,
                           eErrorLevel level)
        {
            int tryCount = 0;
            ors = null;

            while (tryCount < m_maxTryOpenRs)
            {
                if (pOpenRs(sqlstmt,
                            out ors,
                            function,
                            module,
                            title,
                            level,
                            tryCount == m_maxTryOpenRs))
                {
                    return true;
                }
            }
            return false;
        }

Usage Example

Example #1
0
 private bool fillColumns(string sqlstmt)
 {
     var db = new cDataBase(csDatabaseEngine.SQL_SERVER);
     if (db.initDb(m_strConnect))
     {
         DbDataReader rs;
         if (db.openRs(sqlstmt, out rs, "fillColumns", "cConnect", "Update columns's definition", CSKernelClient.eErrorLevel.eErrorInformation))
         {
             for (int i = 0; i < rs.FieldCount; i++)
             {
                 var column = new cColumnInfo();
                 column.setName(rs.GetName(i));
                 column.setPosition(i);
                 column.setColumnType((csDataType)System.Type.GetTypeCode((rs.GetFieldType(i))));
                 m_columnsInfo.add(column, "");
             }
         }
         else
         {
             return false;
         }
     }
     return true;
 }