/*************************************************************************/ public List <Dictionary <string, string> > SelectDct(string Sql) { OdbcConnection Conn = getConnection(); OdbcCommand cmd; OdbcDataReader DaRd; int i = 0; int col = 0; string str; List <Dictionary <string, string> > ListDct = new List <Dictionary <string, string> >(); try { cmd = new OdbcCommand(Sql, Conn); cmd.CommandTimeout = 6000; DaRd = cmd.ExecuteReader(); col = DaRd.FieldCount; while (DaRd.Read()) { Dictionary <string, string> DctStr = new Dictionary <string, string>(); for (i = 0; i < col; i++) { str = DaRd.IsDBNull(i) ? "" : DaRd.GetValue(i).ToString(); DctStr.Add(DaRd.GetName(i), str); } ListDct.Add(DctStr); } } catch (Exception) { ListDct = new List <Dictionary <string, string> >(); } Conn.Close(); return(ListDct); }
public ArrayList SelectAry(string Sql) { OdbcConnection Conn = getConnection(); OdbcCommand cmd; OdbcDataReader DaRd; int i = 0; int col = 0; string str; ArrStr = new ArrayList(); TotCnt = 0; ActCnt = 0; RtnCnt = 0; try { cmd = new OdbcCommand(Sql, Conn); cmd.CommandTimeout = 6000; DaRd = cmd.ExecuteReader(); col = DaRd.FieldCount; string cnm = ""; for (i = 0; i < col; i++) { cnm += DaRd.GetName(i) + ","; } while (DaRd.Read()) { TotCnt++; if (TotCnt >= FstCnt) { ActCnt++; if ((SelCnt != 0) && (ActCnt > SelCnt)) { break; } str = ""; try { for (i = 0; i < col; i++) { if (DaRd.GetValue(i) == null) { str += "^"; } else { str += DaRd.GetValue(i).ToString().Replace("^", "") + "^"; } } ArrStr.Add(str); } catch (Exception) { } } } DaRd.Close(); cmd.Cancel(); } catch (Exception) { ArrStr = new ArrayList(); } Conn.Close(); DaRd = null; cmd = null; Conn = null; return(ArrStr); }