我在使用Winform應用程序中的JRO來壓縮Windows Server 2008 R2(64位)服務器上的訪問數據庫時遇到問題。我也跟着下面的步驟:64位windows 2008服務器上的Compact Access 2007數據庫
發展PC的配置:
操作系統:Windows XP專業版:2002(SP3)32位
的MSOffice 2003安裝:是
的Visual Studio:2010高級
Net框架:4.0。 30319
兩個的WinForm下面的代碼應用程序創建:
應用1:壓縮Access 2007中DB
目標平臺設置爲x86和微軟的Jet新增參考和複製對象2.6庫
配置文件:
<?xml version="1.0"?>
<configuration>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0,Profile=Client"/></startup>
<appSettings>
<add key="SourceDB" value="Provider=Microsoft.ACE.OLEDB.12.0;Data Source=D:\Test\Test2007.accdb;Jet OLEDB:Engine Type=5"/>
<add key="DestDB" value="Provider=Microsoft.ACE.OLEDB.12.0;Data Source=D:\Test\Test2007BK.accdb;Jet OLEDB:Engine Type=5"/>
<add key="AppDB" value="Provider=Microsoft.ACE.OLEDB.12.0;Data Source=D:\Test\Test2007.accdb;" />
</appSettings>
</configuration>
代碼:
string SrcDBName = ConfigurationManager.AppSettings["SourceDB"];
string DestDBName = ConfigurationManager.AppSettings["DestDB"];
int ReturnCode = 0;
JRO.JetEngine objJRO = null;
try
{
MessageBox.Show("Start Compact");
objJRO = new JRO.JetEngine();
objJRO.CompactDatabase(SrcDBName, DestDBName);
MessageBox.Show("End Compact");
}
catch (Exception ex)
{
MessageBox.Show("Error in Compact");
ReturnCode = -1;
StackTrace STrace = new StackTrace(ex, true);
StackFrame StkFrame = STrace.GetFrame(STrace.FrameCount - 1);
string Disp_Msg = "Message:\t" + ex.Message + Environment.NewLine;
Disp_Msg += "Error Date:\t" + DateTime.Now.ToString("dddd, MMM d yyyy HH:mm:ss");
//MessageBox.Show(Disp_Msg, "Compact Utility", MessageBoxButtons.OK, MessageBoxIcon.Error);
File.AppendAllText(Path.GetDirectoryName(Application.ExecutablePath) + @"\CompactErr.txt", Disp_Msg + Environment.NewLine + "Stack Trace:\t" + ex.StackTrace + Environment.NewLine + Environment.NewLine);
}
finally
{
Marshal.ReleaseComObject(objJRO);
objJRO = null;
}
應用2:對於存取測試連接2007
private void Form1_Load(object sender, EventArgs e)
{
try
{
//Connection Test
MessageBox.Show("Start DBConn");
TestConn();
MessageBox.Show("End DBConn");
}
catch (Exception ex)
{
MessageBox.Show("Error in Conn Opening");
string Disp_Msg = "Message:\t" + ex.Message + Environment.NewLine;
Disp_Msg += "Error Date:\t" + DateTime.Now.ToString("dddd, MMM d yyyy HH:mm:ss");
File.AppendAllText(Path.GetDirectoryName(Application.ExecutablePath) + @"\CompactErr.txt", Disp_Msg + Environment.NewLine + "Stack Trace:\t" + ex.StackTrace + Environment.NewLine + Environment.NewLine);
}
}
public void TestConn()
{
string strConnectionString = ConfigurationManager.AppSettings["AppDB"];
DbConnection objConnection;
DbProviderFactory objFactory = OleDbFactory.Instance;
objConnection = objFactory.CreateConnection();
objConnection.ConnectionString = strConnectionString;
objConnection.Open();
objConnection.Close();
}
現在高於2 ex e爲部署的Win2008服務器上:
服務器詳細信息:
的Windows Server 2008 R2(SP1) - 64
NO的MSOffice
NO的Visual Studio
安裝:Microsoft Office Access數據庫引擎2010
案例1:安裝Access DB Engine 2010(64位)時:
鏈接:http://www.microsoft.com/download/en/details.aspx?id=13255
- 連接訪問2007(Test2007.accdb)正確地完成
- 在執行步驟2使用JRO DB的緊湊沒有奏效
- 錯誤消息:
消息:未註冊的類
堆棧跟蹤:在JRO.IJetEngine.CompactDatabase(String SourceConnection,String Destconnection) at CompactUtility.Program.Main(String [] args)
案例2:安裝Access數據庫引擎2007年的時候:
鏈接:http://www.microsoft.com/download/en/details.aspx?displaylang=en&id=23734
- 連接訪問2007(Test2007。ACCDB)不這樣做
- 使用JRO在執行步驟1工作正常
- 錯誤信息DB的結構緊湊:
消息:「Microsoft.ACE.OLEDB.12.0」提供者未在本地機器上註冊的。
任何建議/幫助將高度讚賞解決在Windows Server 2008(64位)服務器上工作。
而且審閱下面的鏈接,但沒有幫助:
Microsoft.ACE.OLEDB.12.0 provider is not registered
感謝, 沙阿