0514-86177077
9:00-17:00(工作日)
/// summary> /// 讀取注冊表,根據(jù)Office版本獲取數(shù)據(jù)庫連接字段 /// /summary> /// returns>數(shù)據(jù)庫連接字段/returns> private string GetConnectionString() { string strConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source = "; RegistryKey rk = Registry.LocalMachine; //查詢Office2003 RegistryKey f03 = rk.OpenSubKey(@"SOFTWARE\Microsoft\Office\11.0\Access\InstallRoot\"); //查詢Office2007 RegistryKey f07 = rk.OpenSubKey(@"SOFTWARE\Microsoft\Office\12.0\Access\InstallRoot\"); //查詢Office2010 RegistryKey f10 = rk.OpenSubKey(@"SOFTWARE\Microsoft\Office\14.0\Access\InstallRoot\"); if (f03 != null) { strConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source = "; } else if (f07 != null || f10 != null) { strConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source = "; } return strConnectionString; }
標簽:葫蘆島 保定 招商 石嘴山 常德 昆明 沈陽 鶴崗
上一篇:Access連接數(shù)據(jù)源(ODBC)配置(新手必知)
下一篇:用SQL語句查找Access中某表是否存在的小技巧
Copyright ? 1999-2012 誠信 合法 規(guī)范的巨人網(wǎng)絡通訊始建于2005年
蘇ICP備15040257號-8