1

我有一个 foxpro 数据库,我们正试图通过 VFP ODBC 驱动程序使用 MS Access 2007 写入该数据库(驱动程序是 6.x 版)

这样做有限制吗?无论我们尝试什么,我们都无法写入 foxpro 数据表。

我们正在使用 ODBC
它是 MS VFP 驱动程序
Foxpro 和 access DB 在同一个系统上
为自由表目录设置 ODBC
已检查 foxpro 目录和文件的权限。

我们没有收到任何特定错误,但我们没有在 FP 表上的 Access 中创建新条目的选项,并且我们无法运行将数据从 Access 插入 FP 表的查询。

任何帮助都会很棒

这是代码:

Dim dbs As DAO.Database
Dim rsSQL As DAO.Recordset
Dim strSQL As String
Dim strSQL2 As String
Dim strConnString As String
Set oConn = CreateObject("ADODB.Connection")
strConnString = "Data Source= C:\Program Files\Best Software\Abra Suite\Programs\Data\hrtables.dbf;User ID = ;Password = ; Provider=VFPOLEDB"
oConn.Open strConnString

Set dbs = CurrentDb
strSQL = "Select * from qryAppendClient"
Set rsSQL = dbs.OpenRecordset(strSQL, dbOpenSnapshot)
Do While Not rsSQL.EOF
strSQL2 = "Insert into hrtables  (c1, c2, c3, c4, Code, Company, Desc, GLComp, n1, n2, n3, Rule, "
strSQL2 = strSQL2 & "Table, tccomp, ud1, ud2, ud3) values (""" & rsSQL!c1 & """, """  &       rsSQL!c2 & """, """ & rsSQL!c3
strSQL2 = strSQL2 & """, """ & rsSQL!c3 & """, """ & rsSQL!Code & """, """ & rsSQL!Company & """, """ & rsSQL!Desc & """, """
strSQL2 = strSQL2 & rsSQL!GLComp & """, " & rsSQL!n1 & ", " & rsSQL!n2 & ", " & rsSQL!n3 & ", """
strSQL2 = strSQL2 & rsSQL!Rule & """, """ & rsSQL!Table & """, """ & rsSQL!tccomp & """, """ & rsSQL!ud1 & """, """
strSQL2 = strSQL2 & rsSQL!ud2 & """, """ & rsSQL!ud3 & """)"
oConn.Execute strSQL2

Loop

oConn.Close
rsSQL.Close
4

2 回答 2

3

我的专长是 Visual FoxPro,而不是 Access,但我曾使用 Access 更新 VFP 数据,反之亦然。打开 Visual FoxPro 数据库需要考虑两件事:

1) 数据库版本(FoxPro 2.6、Visual FoxPro 6.0 及更早版本,或 Visual FoxPro 7.0 或更高版本)很重要。在您帖子的开头,您提到了 VFP 6.0 ODBC 驱动程序,它确实打开了 VFP 6 数据库包含的表、空闲表和较旧的 FoxPro 2.6 表。在您的代码中,您指的是 VFP OLE DB 驱动程序,它打开任何包含表、空闲表和旧 FoxPro 2.6 表的 VFP 数据库。区别在于 ODBC 与 OLE DB。

只要确保您没有混淆这两者及其功能。

2) 根据我的经验,我发现获取 VFP 数据的最简单方法是通过 MS Access 中的链接连接。我找到了其他方法(不要问我它们是什么,因为那是很久以前的事了)只是没有用。

里克·舒默 VFP MVP

于 2009-07-28T03:19:36.423 回答
1

我不熟悉 dbOpenSnapShot,快速检查 MSDN 并没有将其显示为 Foxpro 的选项。如果您在打开记录集后检查您的光标类型,我怀疑它将是默认类型。我非常喜欢显式设置属性。你可以在你的连接上试试这个。

  oConn.CursorLocation = adUseClient
  oConn.Mode = adModeReadWrite

对于您的 OpenRecordset 调用,请尝试使用 adOpenStatic。我相信这会给你一个可更新的光标。此外,不支持 CursorLocation、Mode 和 CursorTypes 的某些组合。为了您的开发,我建议您在打开后立即检查您的 CursorType,看看您是否得到了预期的结果。

  Debug.Print rsSQL.CursorType
于 2009-07-27T20:21:21.240 回答