public static void DataTableTest(MainForm frm) { PFDB2 db = new PFDB2(); string connectionString = string.Empty; Stopwatch sw = new Stopwatch(); try { db.ServerName = frm.txtServerName.Text; db.DatabaseName = frm.txtDatabaseName.Text; db.PortNumber = frm.txtPortNumber.Text; db.Username = frm.txtUsername.Text; db.Password = frm.txtPassword.Text; connectionString = db.ConnectionString; _msg.Length = 0; _msg.Append("Connection string is: \r\n"); _msg.Append(connectionString); Program._messageLog.WriteLine(_msg.ToString()); if (frm.txtSQLQuery.Text.Length == 0) { throw new System.Exception("You must specify a SQL query to run."); } sw.Start(); db.OpenConnection(); db.SQLQuery = frm.txtSQLQuery.Text; if (frm.chkIsStoredProcedure.Checked) { db.CommandType = CommandType.StoredProcedure; } else { 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 PFDB2.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); DataTable tab = db.RunQueryDataTable(); db.returnResultAsString += new PFDB2.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) { frm.OutputErrorMessageToLog(ex); } finally { db.CloseConnection(); db = null; if (_textFile.FileIsOpen) { _textFile.CloseFile(); } } }//end DataTableTest