2013-11-01 275 views
2

正如標題所說,我試圖使用openrowset將FoxPro dbf文件導入sql服務器。起初,我試圖將DBF導出到xls文件並使用導入/導出嚮導導入。這通常工作得很好,但是有一個字段有時會包含一個非常長的字符串,並且在從dbf導出到xls期間,該字符串將被截斷爲4096個字符。試圖將FoxPro DBF文件導入到SQL Server

我找到了一個old post,說明了如何使用openrowset完成此操作。

當我嘗試的第一個答案:

select * 
from openrowset('MSDASQL', 'Driver=Microsoft Visual FoxPro Driver; 
SourceDB=\\path\; 
SourceType=DBF', 
'select * from TABLE.DBF') 

我得到的錯誤:

OLE DB provider "MSDASQL" for linked server "(null)" returned message "[Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified". 
Msg 7303, Level 16, State 1, Line 1 
Cannot initialize the data source object of OLE DB provider "MSDASQL" for linked server "(null)". 

當我嘗試了第二個答案:

select * 
from openrowset('VFPOLEDB', 
'\\Path\';'';'', 
'select * from TABLE.DBF') 

我得到的錯誤:

Msg 7403, Level 16, State 1, Line 1 
The OLE DB provider "VFPOLEDB" has not been registered. 

我試圖用regsvr32手動註冊OLE * .dll文件,但只有其中一些工作。在ole32上,oleacc,oleaut32和oleprn我獲得了成功信息。在oleacchooks,oleaccrc,oledlg和oleres我得到這個錯誤:

The module "oleacchooks" was loaded but the 
entry-point DllRegisterServer was not found. 

Make sure that "oleacchooks" is a valid DLL or OCX file 
and then try again 

someinvestigation我嘗試安裝及部件,但是當我試圖安裝FoxPro中msi文件(found here),我得到這個錯誤:

An error occurred while processing the last operation. 
Error code 80110408 - Error occurred reading the application file 

The event log may contain additional troubleshooting information. 

所以,我正式在這裏失去。有沒有人有關於如何使openrowset正常工作或者導入dbf文件的其他方式的建議?

回答

3

Pat,您可以使用DBF Commander Pro執行此任務。

Download it,安裝,然後單擊文件 - >導出到DBMS。在窗口出現時,單擊以建設連接字符串建立按鈕:選擇MS OLEDB提供程序SQL Server,然後從列表中選擇您的服務器,登錄名和密碼,選擇一個數據庫,然後單擊確定:

enter image description here

在「導出到DBMS」窗口中,選擇要將源DBF文件導入到的目標表,然後單擊「導出」。

有關進口和出口DBF到數據庫的更多信息,你可以找到here

P.S.該應用程序有全功能免費試用20天期限。

+0

這似乎已經完成了。萬分感謝。我一直在爲此掙扎數日。我會跟我的老闆談談購買許可證的問題。 – Pat

0

嘗試使用VFPOLEDB.1作爲提供者。您可能遇到驅動程序版本問題。

+0

不幸的是同樣的錯誤。消息7403,級別16,狀態1,行1 OLE DB提供程序「VFPOLEDB.1」尚未註冊。 – Pat

+0

@Pat,您可能必須從Microsoft下載VFP OleDB提供程序,然後使用它... – DRapp

+0

@DRapp謝謝,但我已經做到了。我也卸載/重新安裝了幾次。這就是我從中獲取ole * .dll文件的地方。在這裏找到它:http://msdn.microsoft。com/en-US/vfoxpro/bb190232 – Pat