使用Access 2007写入Foxpro数据库是否有限制?

时间:2009-07-27 15:24:11

标签: ms-access ms-access-2007 foxpro

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

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

We are using ODBC
It is the MS VFP driver
The Foxpro and access DBs are on the same system
The ODBC is setup for Free Table Directory
Permissions on the foxpro directory and files has been checked.

我们没有收到任何特定错误,但我们没有选择在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

2 个答案:

答案 0 :(得分: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中的链接连接。我找到了其他的方法(并且不要问我他们在很久以前的样子)就行不通了。

Rick Schummer VFP MVP

答案 1 :(得分:1)

我不熟悉dbOpenSnapShot,快速检查MSDN并不会将其显示为Foxpro的选项。如果在打开记录集后检查你的cursortype我怀疑它将是默认类型。我是明确设置属性的忠实粉丝。您可以尝试连接。

  oConn.CursorLocation = adUseClient
  oConn.Mode = adModeReadWrite

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

  Debug.Print rsSQL.CursorType