示例#1
0
        private IList <string> GetTableNames()
        {
            //this ensures that the XDbEnvironment.XDbConnectedType get set correctly
            XDbEnvironment.GetConnectionString(m_fileName);

            IList <string> tableNames = new List <string>();

            try
            {
                string[] restrictionValues = new string[4] {
                    null, null, null, "TABLE"
                };
                using (DataTable tables = m_XDbConnection.GetSchema("Tables", restrictionValues))
                {
                    foreach (DataRow table in tables.Rows)
                    {
                        string tableName = table["TABLE_NAME"].ToString();
                        if (IsTableNameFormatCorrect(tableName))
                        {
                            tableNames.Add(tableName);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                string msg = string.Format("{0}\n{1}", Resources.ResourceMessages.InstallMsg, ex.Message);
                ApplicationExceptions.Add(new ApplicationException(msg, ex.InnerException));
            }
            return(tableNames);
        }
示例#2
0
        private void Initialize()
        {
            if (string.IsNullOrEmpty(m_fileName) || !File.Exists(m_fileName))
            {
                string msg = string.Format("{0} does not exist or is null.", string.IsNullOrEmpty(m_fileName) ? "[Invalid file name passed in]" : m_fileName);
                throw new ApplicationException(msg);
            }

            string conStr = XDbEnvironment.GetConnectionString(m_fileName);

            m_XDbConnection = new XDbConnection(conStr);
            try
            {
                m_XDbConnection.Open();
            }
            catch (Exception ex)
            {
                m_XDbConnection = null;
                ApplicationExceptions.Add(new ApplicationException(ex.Message, ex.InnerException));
                return;
            }
            m_XDbType = XDbEnvironment.XDbConnectedType;
        }