大橙子网站建设,新征程启航

为企业提供网站建设、域名注册、服务器等服务

在64位系统上使用PowerShell操作Foxpro-创新互联

操作步骤:

创新互联服务项目包括芙蓉网站建设、芙蓉网站制作、芙蓉网页制作以及芙蓉网络营销策划等。多年来,我们专注于互联网行业,利用自身积累的技术优势、行业经验、深度合作伙伴关系等,向广大中小型企业、政府机构等提供互联网行业的解决方案,芙蓉网站推广取得了明显的社会效益与经济效益。目前,我们服务的客户以成都为中心已经辐射到芙蓉省份的部分城市,未来相信会继续扩大服务区域并继续获得客户的支持与信任!

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

另外有需要云服务器可以了解下创新互联cdcxhl.cn,海内外云服务器15元起步,三天无理由+7*72小时售后在线,公司持有idc许可证,提供“云服务器、裸金属服务器、高防服务器、香港服务器、美国服务器、虚拟主机、免备案服务器”等云主机租用服务以及企业上云的综合解决方案,具有“安全稳定、简单易用、服务可用性高、性价比高”等特点与优势,专为企业上云打造定制,能够满足用户丰富、多元化的应用场景需求。


新闻名称:在64位系统上使用PowerShell操作Foxpro-创新互联
文章起源:http://dzwzjz.com/article/ceedsd.html
在线咨询
服务热线
服务热线:028-86922220
TOP