我需要将Access应用程序中的数据导入VFP表。我已经在网上找到了将VFP数据读入Access的解决方案,但并非如此。 MS *建议的连接字符串似乎缺少了一些东西,因为我不断收到一个对话框询问我源数据的类型
如果有任何建议和/或解释,我将不胜感激。
/伯纳德
答案 0 :(得分:1)
如果您在VFP中编写程序,则可以在不使用" DSN"的情况下从VFP连接到Access数据库,但需要完整的连接字符串设置。完成后,您可以将数据查询到本地VFP游标,然后在VFP中执行您想要的操作...复制到VFP表,查询数据子集,按任何条件将记录添加到另一个VFP表你需要处理。
nAccessHandle = sqlstringconnect( "DRIVER=Microsoft Access Driver (*.mdb, *.accdb); DBQ=C:\YourFullPath\YourAccessDatabase.accdb;" )
if nAccessHandle < 1
messagebox( "Invalid connection to access database" )
return
endif
*/ Valid handle, now, query down the data to a local VFP cursor
nSQLAns = SQLExec( nAccessHandle, "select * from YourAccessTable", "C_CursorInVFP" )
if nSQLAns < 1
messagebox( "Unable to get any data..." )
sqldisconnect( nAccessHandle )
return
endif
*/ Done with connection
sqldisconnect( nAccessHandle )
select C_CursorInVFP
copy to C:\SomeOtherPath\NowItsAVFPTable
*/ Or, query from it within VFP or loop from it...
select C_CursorInVFP
scan
*/ Look for records in VFP to do/ignore as needed...
select * from SomeVFPTable ;
where SomeKey = C_CursorInVFP.KeyFromAccessTable;
into cursor C_WasItFound readwrite
if reccount( "C_WasItFound" ) > 0
*/ Do what if it WAS found
else
*/ Do what if it WAS NOT found
endif
endscan