public static void DataTableTest(MainForm frm) { string dbPlatformDesc = DatabasePlatform.Unknown.ToString(); PFDatabase db = null; string connStr = string.Empty; string nmSpace = string.Empty; string clsName = string.Empty; string dllPath = string.Empty; Stopwatch sw = new Stopwatch(); try { _msg.Length = 0; _msg.Append("DataTableTest started ...\r\n"); Program._messageLog.WriteLine(_msg.ToString()); string[] parsedConnectionInfo = frm.cboConnectionString.Text.Split('|'); dbPlatformDesc = parsedConnectionInfo[0]; connStr = parsedConnectionInfo[1]; string configValue = AppConfig.GetStringValueFromConfigFile(dbPlatformDesc, string.Empty); string[] parsedConfig = configValue.Split('|'); nmSpace = parsedConfig[0]; clsName = parsedConfig[1]; dllPath = parsedConfig[2]; if (frm.txtSQLQuery.Text.Length == 0) { throw new System.Exception("You must specify a SQL query to run."); } _msg.Length = 0; _msg.Append("Connecting to "); _msg.Append(dbPlatformDesc); Program._messageLog.WriteLine(_msg.ToString()); sw.Start(); db = new PFDatabase(dbPlatformDesc, dllPath, nmSpace + "." + clsName); db.ConnectionString = connStr; db.OpenConnection(); db.SQLQuery = frm.txtSQLQuery.Text; db.CommandType = CommandType.Text; sw.Stop(); _msg.Length = 0; _msg.Append("Open connection time: "); _msg.Append(sw.FormattedElapsedTime); Program._messageLog.WriteLine(_msg.ToString()); sw.Start(); DataTable tab1 = db.RunQueryDataTable(); db.returnResult += new PFDatabase.ResultDelegate(OutputResults); db.ProcessDataTable(tab1); sw.Stop(); _msg.Length = 0; _msg.Append("Process Table time: "); _msg.Append(sw.FormattedElapsedTime); Program._messageLog.WriteLine(_msg.ToString()); if (_textFile.FileIsOpen) { _textFile.CloseFile(); } _textFile.OpenFile(@"c:\temp\TableTestExtract.txt", PFFileOpenOperation.OpenFileForWrite); //sw.Start(); DataTable tab = db.RunQueryDataTable(); //db.returnResultAsString += new PFdb.ResultAsStringDelegate(OutputExtractFormattedData); db.returnResultAsString += new PFDatabase.ResultAsStringDelegate(OutputResultsToFile); db.ExtractDelimitedDataFromTable(tab, ",", "\r\n", true); sw.Stop(); _msg.Length = 0; _msg.Append("Extract Delimiated Table time: "); _msg.Append(sw.FormattedElapsedTime); Program._messageLog.WriteLine(_msg.ToString()); tab = null; sw.Start(); if (_textFile.FileIsOpen) { _textFile.CloseFile(); } _textFile.OpenFile(@"c:\temp\TableTestExtractFXL.txt", PFFileOpenOperation.OpenFileForWrite); tab = db.RunQueryDataTable(); db.ExtractFixedLengthDataFromTable(tab, true, true, false); sw.Stop(); _msg.Length = 0; _msg.Append("Extract Fixed Length Table time: "); _msg.Append(sw.FormattedElapsedTime); Program._messageLog.WriteLine(_msg.ToString()); db.SaveDataTableToXmlSchemaFile(tab, @"c:\temp\Testtab.xsd"); db.SaveDataTableToXmlFile(tab, @"c:\temp\Testtab.xml"); db.SaveDataTableWithSchemaToXmlFile(tab, @"c:\temp\Testtabplus.xml"); DataTable tab2 = db.LoadXmlFileToDataTable(@"c:\temp\Testtabplus.xml");; int numRows = tab2.Rows.Count; PFDataProcessor dataProcessor = new PFDataProcessor(); XmlDocument xmlDoc = dataProcessor.CopyDataTableToXmlDocument(tab); Program._messageLog.WriteLine("\r\n" + xmlDoc.OuterXml + "\r\n"); } catch (System.Exception ex) { _msg.Length = 0; _msg.Append(AppGlobals.AppMessages.FormatErrorMessage(ex)); Program._messageLog.WriteLine(_msg.ToString()); AppMessages.DisplayErrorMessage(_msg.ToString(), _saveErrorMessagesToAppLog); } finally { if (db != null) { if (db.IsConnected) { db.CloseConnection(); } db = null; } _msg.Length = 0; _msg.Append("\r\n... DataTableTest finished."); Program._messageLog.WriteLine(_msg.ToString()); } }