public static DataTable CSVquery(string queryST, ref string retErr) { DataTable resultsDT = new DataTable("resultsDT"); try { LogQuery oLogQuery = new LogQuery(); MSUtil.COMCSVInputContextClassClass oInputFormat = new MSUtil.COMCSVInputContextClassClass(); // Execute the query LogRecordSet oRecordSet = oLogQuery.Execute(queryST, oInputFormat); int i = 0; for (; i < oRecordSet.getColumnCount(); i++) { string colnm; colnm = oRecordSet.getColumnName(i); resultsDT.Columns.Add(new DataColumn(colnm, typeof(string))); } for (; !oRecordSet.atEnd(); oRecordSet.moveNext()) { MSUtil.ILogRecord rowLP = null; rowLP = oRecordSet.getRecord(); DataRow dr = resultsDT.NewRow(); for (int ct = 0; ct < i; ct++) { dr[ct] = rowLP.getValue(ct); } resultsDT.Rows.Add(dr); } // Close the recordset oRecordSet.close(); } catch (Exception exc) { retErr = "Unexpected error: " + exc.Message; } return(resultsDT); }
public static DataTable CSVquery(string queryST, ref string retErr) { DataTable resultsDT = new DataTable("resultsDT"); try { LogQuery oLogQuery = new LogQuery(); MSUtil.COMCSVInputContextClassClass oInputFormat = new MSUtil.COMCSVInputContextClassClass(); // Execute the query LogRecordSet oRecordSet = oLogQuery.Execute(queryST, oInputFormat); int i = 0; for (; i < oRecordSet.getColumnCount(); i++) { string colnm; colnm = oRecordSet.getColumnName(i); resultsDT.Columns.Add(new DataColumn(colnm, typeof(string))); } for (; !oRecordSet.atEnd(); oRecordSet.moveNext()) { MSUtil.ILogRecord rowLP = null; rowLP = oRecordSet.getRecord(); DataRow dr = resultsDT.NewRow(); for (int ct = 0; ct < i; ct++) { dr[ct] = rowLP.getValue(ct); } resultsDT.Rows.Add(dr); } // Close the recordset oRecordSet.close(); } catch (Exception exc) { retErr = "Unexpected error: " + exc.Message; } return resultsDT; }