/// <summary> /// Get linked server name by mdb/accdb file path. /// </summary> /// <param name="sMDBPath"></param> /// <returns></returns> public static string GetLinkedSrvName(string sMDBPath) { string sLinkedSrvName; if (_linkedSrvNameDictionary.TryGetValue(sMDBPath, out sLinkedSrvName)) { return(sLinkedSrvName); } sLinkedSrvName = CalculateLinkedSrvName(sMDBPath); CheckSqlLinkedServer(sMDBPath); _linkedSrvNameDictionary[sMDBPath] = sLinkedSrvName; // Evaluate memo tables cache. List <string> memoLst = new List <string>(); using (XDbConnection con = new XDbConnection(GetAceConnectString(sMDBPath))) { if (!_memoTables.TryGetValue(CalculateLinkedSrvName(sMDBPath), out memoLst)) { con.Open(); _memoTables[CalculateLinkedSrvName(sMDBPath)] = GetMemoTableList(con); } } return(sLinkedSrvName); }
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; }