예제 #1
0
        public static void RunReaderTest(MainForm frm, PFSQLServerCE40 db)
        {
            string query = string.Empty;

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

            try
            {
                query = frm.txtQuery.Text;
                db.OpenConnection();
                SqlCeDataReader rdr = (SqlCeDataReader)db.RunQueryDataReader(query);

                db.returnResult += new PFSQLServerCE40.ResultDelegate(OutputResults);
                //sqlce.returnResultAsString += new PFSQLServerCE40.ResultAsStringDelegate(OutputResultsAsString);
                db.ProcessDataReader(rdr);
                rdr.Close();

                rdr = (SqlCeDataReader)db.RunQueryDataReader(query);
                db.SaveDataReaderToXmlFile(rdr, @"c:\temp\TestCeRdr.xml");
                rdr.Close();

                rdr = (SqlCeDataReader)db.RunQueryDataReader(query);
                db.SaveDataReaderWithSchemaToXmlFile(rdr, @"c:\temp\TestCeRdrPlus.xml");
                rdr.Close();

                rdr = (SqlCeDataReader)db.RunQueryDataReader(query);
                db.SaveDataReaderToXmlSchemaFile(rdr, @"c:\temp\TestCeRdr.xsd");
                rdr.Close();



                rdr = (SqlCeDataReader)db.RunQueryDataReader(query);
                PFDataProcessor dataProcessor = new PFDataProcessor();
                XmlDocument     xmlDoc        = dataProcessor.CopyDataTableToXmlDocument(db.ConvertDataReaderToDataTable(rdr));
                Program._messageLog.WriteLine("\r\n" + xmlDoc.OuterXml + "\r\n");
                rdr.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("...RunReaderTest Finished.");
                Program._messageLog.WriteLine(_msg.ToString());
            }
        }