溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

在64位系統上使用PowerShell操作Foxpro

發布時間:2020-03-15 13:53:27 來源:網絡 閱讀:6721 作者:UltraSQL 欄目:關系型數據庫

操作步驟:


1. 下載Foxpro的OLEDB驅動VFPOLEDBSetup.msi,安裝,選擇允許everyone運行。


2. 注冊OLEDB驅動:

regsvr32 /s "C:\Program Files (x86)\Common Files\system\ole db\vfpoledb.dll"


3. 運行x86版PowerShell:

在64位系統上使用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位系統上使用PowerShell操作Foxpro


坑列表:


  1. 從Foxpro驅動描述:

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

  2. ODBC驅動分為32位和64位。只有編譯為32位的應用程序才能調用32位的ODBC驅動。

    "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位系統上使用PowerShell操作Foxpro

  3. 安裝了Visual Foxpro后,會安裝32位ODBC驅動VFPODBC.DLL。

    在64位系統上使用PowerShell操作Foxpro

  4. 安裝OLEDB驅動時要選擇允許everyone運行。

  5. 要注冊vfpoledb.dll。

  6. OLEDB驅動的Provider為vfpoledb.1。

  7. 要在32位PowerShell下運行來調用該驅動。


后記:


嘗試在32位PowerShell下操作ODBC驅動,失敗。

$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位系統上使用PowerShell操作Foxpro

但在32位操作系統上運行是正常。若其他語言在開發時應編譯為32位版本。


向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

亚洲午夜精品一区二区_中文无码日韩欧免_久久香蕉精品视频_欧美主播一区二区三区美女