在64位系统上使用PowerShell操作Foxpro
admin
2023-02-08 12:20:04
0

操作步骤:


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位版本。


相关内容

热门资讯

玩家攻略科普“旺旺福建麻将.是... 网上科普关于“旺旺福建麻将有没有挂”话题很是火热,小编也是针对旺旺福建麻将作*弊开挂的方法以及开挂对...
【第一资讯】“福州十八扑.怎么... 有 亲,根据资深记者爆料福州十八扑是可以开挂的,确实有挂(咨询软件无需打...
【今日要闻】“聚友互娱.到底有... 您好:聚友互娱这款游戏可以开挂,确实是有挂的,需要了解加客服微信【9784099】很多玩家在这款游戏...
玩家攻略科普“TT语音.究竟有... 家人们!今天小编来为大家解答TT语音透视挂怎么安装这个问题咨询软件客服徽9752949的挂在哪里买很...
胡锡进:若日本拥核,中国“不首... 日本首相官邸一名负责安保政策的高官日前向媒体称,日本应该拥有核武器。这是日方一次大胆的放风测试。日本...
【第一资讯】“西兵互娱牛牛.到... 家人们!今天小编来为大家解答西兵互娱牛牛透视挂怎么安装这个问题咨询软件客服徽4282891的挂在哪里...
【第一消息】“聚友.怎么开挂?... 【第一消息】“聚友.怎么开挂?”太坑了原来有挂您好,聚友这个游戏其实有挂的,确实是有挂的,需要了解加...
信仰与突围:2026人工智能趋... 王齐昂 独立科技观察者 谁也无法想到,ChatGPT迎来三周年之际,没有庆祝和纪念,反而是内部发布的...
今日重大消息“微乐捉鸡麻将.究... 您好:微乐捉鸡麻将这款游戏可以开挂,确实是有挂的,需要了解加客服微信【9784099】很多玩家在这款...
今日重磅消息“皇豪众娱牛牛.辅... 您好:皇豪众娱牛牛这款游戏可以开挂,确实是有挂的,需要了解加客服微信【9784099】很多玩家在这款...