操作步驟:
成都創(chuàng)新互聯(lián)是一家集網(wǎng)站建設(shè),北鎮(zhèn)企業(yè)網(wǎng)站建設(shè),北鎮(zhèn)品牌網(wǎng)站建設(shè),網(wǎng)站定制,北鎮(zhèn)網(wǎng)站建設(shè)報(bào)價(jià),網(wǎng)絡(luò)營(yíng)銷(xiāo),網(wǎng)絡(luò)優(yōu)化,北鎮(zhèn)網(wǎng)站推廣為一體的創(chuàng)新建站企業(yè),幫助傳統(tǒng)企業(yè)提升企業(yè)形象加強(qiáng)企業(yè)競(jìng)爭(zhēng)力??沙浞譂M(mǎn)足這一群體相比中小企業(yè)更為豐富、高端、多元的互聯(lián)網(wǎng)需求。同時(shí)我們時(shí)刻保持專(zhuān)業(yè)、時(shí)尚、前沿,時(shí)刻以成就客戶(hù)成長(zhǎng)自我,堅(jiān)持不斷學(xué)習(xí)、思考、沉淀、凈化自己,讓我們?yōu)楦嗟钠髽I(yè)打造出實(shí)用型網(wǎng)站。
1. 下載Foxpro的OLEDB驅(qū)動(dòng)VFPOLEDBSetup.msi,安裝,選擇允許everyone運(yùn)行。
2. 注冊(cè)O(shè)LEDB驅(qū)動(dòng):
regsvr32 /s "C:\Program Files (x86)\Common Files\system\ole db\vfpoledb.dll"
3. 運(yùn)行x86版PowerShell:
$ConnString = "Provider=vfpoledb.1;Data Source=c:\accounts.dbf;Collating Sequence=machine;" $Conn = new-object System.Data.OleDb.OleDbConnection($connString) $conn.open() $cmd = new-object System.Data.OleDb.OleDbCommand("select * from accounts", $Conn) $DataAdapter = new-object System.Data.OleDb.OleDbDataAdapter($cmd) $dataset = new-object System.Data.Dataset $DataAdapter.fill($dataset) $dataset.Tables[0]
坑列表:
從Foxpro驅(qū)動(dòng)描述:
“The VFPODBC driver is no longer supported. We strongly recommend using the Visual FoxPro OLE DB provider as a replacement.”
ODBC驅(qū)動(dòng)分為32位和64位。只有編譯為32位的應(yīng)用程序才能調(diào)用32位的ODBC驅(qū)動(dòng)。
"A 32-bit app uses a 32-bit ODBC driver even when installed on 64-bit Windows. But on 64-bit systems, there are two views on ODBC - one is 64-bit, the other is 32-bit. It looks like you opened the default 64-bit view which doesn't show the 32-bit ODBC drivers. To solve this go to c:\windows, there you see a folder named SysWOW64. Here you find odbcad32.exe. After launching the exe you can add a new system dsn or user dsn for the required ODBC driver. Configure it as usual. All other ODBC drivers you have been missing will appear there."
安裝了Visual Foxpro后,會(huì)安裝32位ODBC驅(qū)動(dòng)VFPODBC.DLL。
安裝OLEDB驅(qū)動(dòng)時(shí)要選擇允許everyone運(yùn)行。
要注冊(cè)vfpoledb.dll。
OLEDB驅(qū)動(dòng)的Provider為vfpoledb.1。
要在32位PowerShell下運(yùn)行來(lái)調(diào)用該驅(qū)動(dòng)。
后記:
嘗試在32位PowerShell下操作ODBC驅(qū)動(dòng),失敗。
$ConnString ="Driver={Microsoft Visual FoxPro Driver};SourceType=DBF;SourceDB='c:\foxpro\';Exclusive=No;Collate=Machine;NULL=NO;DELETED=NO;BACKGROUNDFETCH=NO;" $Connection = New-Object System.Data.Odbc.OdbcConnection $Connection.ConnectionString = $ConnString $Connection.Open() $Command = New-Object System.Data.Odbc.OdbcCommand $Command.Connection = $Connection $Command.CommandText = $Query $Reader = $Command.ExecuteReader() $Counter = $Reader.FieldCount while ($Reader.Read()) { $SQLObject = @{} for ($i = 0; $i -lt $Counter; $i++) { $SQLObject.Add( $Reader.GetName($i), $Reader.GetValue($i)); } $SQLObject } $Connection.Close() $Reader.Close()
但在32位操作系統(tǒng)上運(yùn)行是正常。若其他語(yǔ)言在開(kāi)發(fā)時(shí)應(yīng)編譯為32位版本。