Exemple #1
0
        public static void RunDataTableTest(MainForm frm, PFSQLServerCE40 db)
        {
            string    query = string.Empty;
            DataTable tab   = null;

            _msg.Length = 0;
            _msg.Append("Running RunDataTableTest ...");
            Program._messageLog.WriteLine(_msg.ToString());

            try
            {
                query = frm.txtQuery.Text;
                db.OpenConnection();
                tab         = db.RunQueryDataTable(query, "tabtest");
                _msg.Length = 0;
                _msg.Append("Number of rows in table: ");
                _msg.Append(tab.Rows.Count.ToString("#,##0"));
                Program._messageLog.WriteLine(_msg.ToString());

                db.returnResult += new PFSQLServerCE40.ResultDelegate(OutputResults);
                db.ProcessDataTable(tab);
                db.returnResultAsString += new PFSQLServerCE40.ResultAsStringDelegate(OutputExtractFormattedData);
                db.ExtractDelimitedDataFromTable(tab, ",", "\r\n", true);

                tab.TableName = "TabTestCe";
                db.SaveDataTableToXmlFile(tab, @"c:\temp\TestCeTab.xml");
                db.SaveDataTableWithSchemaToXmlFile(tab, @"c:\temp\TestCeTabPlus.xml");
                db.SaveDataTableToXmlSchemaFile(tab, @"c:\temp\TestCeTab.xsd");

                PFDataProcessor dataProcessor = new PFDataProcessor();
                XmlDocument     xmlDoc        = dataProcessor.CopyDataTableToXmlDocument(tab);
                Program._messageLog.WriteLine("\r\n" + xmlDoc.OuterXml + "\r\n");


                db.CloseConnection();
            }
            catch (System.Exception ex)
            {
                _msg.Length = 0;
                _msg.Append(AppGlobals.AppMessages.FormatErrorMessage(ex));
                Program._messageLog.WriteLine(_msg.ToString());
                AppMessages.DisplayErrorMessage(_msg.ToString(), _saveErrorMessagesToAppLog);
            }
            finally
            {
                _msg.Length = 0;
                _msg.Append("...RunDataTableTest Finished.");
                Program._messageLog.WriteLine(_msg.ToString());
            }
        }