Пример #1
0
        public static void RunDatasetTest(MainForm frm, PFSQLServerCE40 db)
        {
            string  query = string.Empty;
            DataSet ds;
            int     numRows = -1;

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

            try
            {
                query = frm.txtQuery.Text;
                db.OpenConnection();
                ds = db.RunQueryDataset(query, "dsTabCe");
                if (ds.Tables["dstest"] != null)
                {
                    if (ds.Tables["dstest"].Rows.Count > 0)
                    {
                        numRows = ds.Tables["dstest"].Rows.Count;
                    }
                }
                _msg.Length = 0;
                _msg.Append("Number of rows in ");
                _msg.Append(ds.Tables[0].TableName);
                _msg.Append(": ");
                _msg.Append(numRows.ToString("#,##0"));
                Program._messageLog.WriteLine(_msg.ToString());

                db.returnResult += new PFSQLServerCE40.ResultDelegate(OutputResults);
                db.ProcessDataSet(ds);
                db.returnResultAsString += new PFSQLServerCE40.ResultAsStringDelegate(OutputExtractFormattedData);
                db.ExtractDelimitedDataFromDataSet(ds, "\t", "\r\n", true);

                ds.DataSetName = "dsDataSetCe";
                db.SaveDataSetToXmlFile(ds, @"c:\Temp\TestCeDs.xml");
                db.SaveDataSetWithSchemaToXmlFile(ds, @"c:\Temp\TestCeDsPlus.xml");
                db.SaveDataSetToXmlSchemaFile(ds, @"c:\Temp\TestCeDs.xsd");

                PFDataProcessor dataProcessor = new PFDataProcessor();
                XmlDocument     xmlDoc        = dataProcessor.CopyDataSetToXmlDocument(ds);
                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("...RunDatasetTest Finished.");
                Program._messageLog.WriteLine(_msg.ToString());
            }
        }