Esempio n. 1
0
        public static void RunResultsetTest(MainForm frm, PFSQLServerCE40 db)
        {
            SqlCeResultSet res   = null;
            string         query = string.Empty;

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

            try
            {
                query = frm.txtQuery.Text;
                db.OpenConnection();
                res = db.RunQueryResultset(query);
                if (res.HasRows)
                {
                    db.returnResult += new PFSQLServerCE40.ResultDelegate(OutputResults);
                    //sqlce.returnResultAsString += new PFSQLServerCE40.ResultAsStringDelegate(OutputResultsAsString);
                    db.ProcessResultSet(res);
                    res.Close();
                    res = db.RunQueryResultset(query);
                    db.returnResultAsString += new PFSQLServerCE40.ResultAsStringDelegate(OutputExtractFormattedData);
                    db.ExtractDelimitedDataFromResultSet(res, "\t", "\r\n", true);
                    res.Close();

                    res = db.RunQueryResultset(query);
                    db.SaveResultSetToXmlFile(res, @"c:\temp\TestCeRes.xml");
                    res.Close();

                    res = db.RunQueryResultset(query);
                    db.SaveResultSetWithSchemaToXmlFile(res, @"c:\temp\TestCeResPlus.xml");
                    res.Close();

                    res = db.RunQueryResultset(query);
                    db.SaveResultSetToXmlSchemaFile(res, @"c:\temp\TestCeRes.xsd");
                    res.Close();

                    res = db.RunQueryResultset(query);
                    PFDataProcessor dataProcessor = new PFDataProcessor();
                    XmlDocument     xmlDoc        = dataProcessor.CopyDataTableToXmlDocument(PFSQLServerCE40.ConvertResultSetToDataTable(res, "ResultTable"));
                    Program._messageLog.WriteLine("\r\n" + xmlDoc.OuterXml + "\r\n");
                    res.Close();
                }


                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("...RunResultsetTest Finished.");
                Program._messageLog.WriteLine(_msg.ToString());
            }
        }