在64位系統(tǒng)上使用PowerShell操作Foxpro

操作步驟:

成都創(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ò)營銷,網(wǎng)絡(luò)優(yōu)化,北鎮(zhèn)網(wǎng)站推廣為一體的創(chuàng)新建站企業(yè),幫助傳統(tǒng)企業(yè)提升企業(yè)形象加強(qiáng)企業(yè)競爭力??沙浞譂M足這一群體相比中小企業(yè)更為豐富、高端、多元的互聯(lián)網(wǎng)需求。同時(shí)我們時(shí)刻保持專業(yè)、時(shí)尚、前沿,時(shí)刻以成就客戶成長自我,堅(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:

在64位系統(tǒng)上使用PowerShell操作Foxpro

$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]

在64位系統(tǒng)上使用PowerShell操作Foxpro

坑列表:


  1. 從Foxpro驅(qū)動(dòng)描述:

    “The VFPODBC driver is no longer supported. We strongly recommend using the Visual FoxPro OLE DB provider as a replacement.”

  2. 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."

    在64位系統(tǒng)上使用PowerShell操作Foxpro

  3. 安裝了Visual Foxpro后,會(huì)安裝32位ODBC驅(qū)動(dòng)VFPODBC.DLL。

    在64位系統(tǒng)上使用PowerShell操作Foxpro

  4. 安裝OLEDB驅(qū)動(dòng)時(shí)要選擇允許everyone運(yùn)行。

  5. 要注冊(cè)vfpoledb.dll。

  6. OLEDB驅(qū)動(dòng)的Provider為vfpoledb.1。

  7. 要在32位PowerShell下運(yùn)行來調(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()

在64位系統(tǒng)上使用PowerShell操作Foxpro

但在32位操作系統(tǒng)上運(yùn)行是正常。若其他語言在開發(fā)時(shí)應(yīng)編譯為32位版本。

文章標(biāo)題:在64位系統(tǒng)上使用PowerShell操作Foxpro
當(dāng)前URL:http://muchs.cn/article14/pgogge.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供靜態(tài)網(wǎng)站外貿(mào)建站、網(wǎng)站內(nèi)鏈、定制網(wǎng)站、網(wǎng)站建設(shè)營銷型網(wǎng)站建設(shè)

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場,如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)

h5響應(yīng)式網(wǎng)站建設(shè)