private void GenerateXMLFromMDB(string pFilename)
        {
            mfSysTableExport            = false;
            mfSysTablePVEntityGenerator = false;

            mDBDefinition             = new dbdefinition();
            mDBDefinition.generatedon = DateTime.Now;

            // Generate entities
            ArrayList alEntities = new ArrayList();

            ADODB.Connection con = new ADODB.ConnectionClass();
            try {
                con.Open(DBServerHelper.getDatabaseOleDbConnectionString(pFilename), "", "", 0);
            }
            catch (Exception ex) {
                throw new Exception("Unable to open database file:\n" + ex.Message);
            }
            ADOX.Catalog cat = new ADOX.Catalog();
            cat.ActiveConnection = con;

            mStatusHandler.InitStatus("Analyzing MDB table structure...", cat.Tables.Count);

            int intTable          = 0;
            int intTableRealCount = 0;

            foreach (ADOX.Table tbl in cat.Tables)
            {
                intTable++;
                if (!IsSystemTableName(tbl.Name))
                {
                    intTableRealCount++;
                    mStatusHandler.SetStatus("Analyzing table '" + tbl.Name + "'...", intTable);

                    alEntities.Add(GenerateEntity(tbl, con));
                }
                else
                {
                    // Check if settings from older versions of SQLExporter or PVEntityGenerator exist
                    if (!mfSysTableExport)
                    {
                        mfSysTableExport = tbl.Name.ToLower().Equals("_export");
                    }
                    if (!mfSysTablePVEntityGenerator)
                    {
                        mfSysTablePVEntityGenerator = tbl.Name.ToLower().Equals("_pventitygenerator");
                    }
                }
            }
            con.Close();

            if (alEntities.Count != 0)
            {
                mDBDefinition.entities = (dbdefinitionEntity[])alEntities.ToArray(typeof(dbdefinitionEntity));
            }

            mStatusHandler.ClearStatus("Analyzed " + intTableRealCount + " table(s).");
        }
示例#2
0
 public static ADODB.Connection GetMDBConnectionADODB(string pFilename)
 {
     ADODB.Connection con = new ADODB.ConnectionClass();
     try {
         con.Open(DBServerHelper.getDatabaseOleDbConnectionString(pFilename), "", "", 0);
         return(con);
     }
     catch (Exception ex) {
         throw new Exception("Unable to open database file:\n" + ex.Message);
     }
 }
示例#3
0
        public static System.Data.OleDb.OleDbConnection GetMDBConnectionOLEDB(string pFilename)
        {
            try {
                System.Data.OleDb.OleDbConnection con = new System.Data.OleDb.OleDbConnection
                                                            (DBServerHelper.getDatabaseOleDbConnectionString(pFilename));

                con.Open();
                return(con);
            }
            catch (Exception ex) {
                throw new Exception("Unable to open database file:\n" + ex.Message);
            }
        }