Beispiel #1
0
        public bool ExecuteProc(String strProcName, ref SqlParameter[] aryProcParams, out STableRecordSet RecordSets)
        {
            SqlCommand dbCmd = m_dbConnect.CreateCommand();

            dbCmd.CommandText = strProcName;
            dbCmd.CommandType = CommandType.StoredProcedure;

            if (aryProcParams != null)
            {
                dbCmd.Parameters.AddRange(aryProcParams); // Past the params
            }

            RecordSets = new STableRecordSet();
            SqlDataReader dbReader = dbCmd.ExecuteReader();

            if (dbReader == null)
            {
                return(false);
            }

            //////////////////////////////////////////////////////////////////////////
            // Init data to SqlDataReader
            // Get Field names

            RecordSets.m_straFieldNames = new ArrayList();
            Int32 nFieldCount = dbReader.FieldCount;

            for (Int32 i = 0; i < nFieldCount; i++)
            {
                RecordSets.m_straFieldNames.Add(dbReader.GetName(i));
            }

            RecordSets.m_str2aRecords = new ArrayList();
            // Get Records
            while (dbReader.Read())
            {
                ArrayList aryRecord = new ArrayList(nFieldCount);

                for (Int32 i = 0; i < nFieldCount; i++)
                {
                    aryRecord.Add(dbReader[i].ToString());
                }

                RecordSets.m_str2aRecords.Add(aryRecord);
            }
            dbReader.Close();

            return(true);
        }
Beispiel #2
0
        public bool ExecuteSQL(String strSQL, out STableRecordSet RecordSets)
        {
            RecordSets = new STableRecordSet();
            RecordSets.m_straFieldNames = new ArrayList();

            SqlCommand dbCmd = m_dbConnect.CreateCommand();

            dbCmd.CommandText = strSQL;

            SqlDataReader dbReader = dbCmd.ExecuteReader();

            //////////////////////////////////////////////////////////////////////////
            // Init data to SqlDataReader
            // Get Field names
            Int32 nFieldCount = dbReader.FieldCount;

            for (Int32 i = 0; i < nFieldCount; i++)
            {
                RecordSets.m_straFieldNames.Add(dbReader.GetName(i));
            }

            RecordSets.m_str2aRecords = new ArrayList();
            // Get Records
            while (dbReader.Read())
            {
                ArrayList aryRecord = new ArrayList(nFieldCount);

                for (Int32 i = 0; i < nFieldCount; i++)
                {
                    String strFieldValue = dbReader[i].ToString();
                    aryRecord.Add(strFieldValue);
                }

                RecordSets.m_str2aRecords.Add(aryRecord);
            }
            dbReader.Close();

            return(true);
        }