用adodb怎么连接一个dbf文件?

itme99 2003-10-16 02:57:04
怎样连接import.dbf文件。
do while ....

FileCopy App.Path & "\EXPVCH.STD", App.Path & "\Import.dbf" '权限07

Dim rsdbf As ADODB.Recordset
Dim condbf As ADODB.Connection
Set rsdbf = New ADODB.Recordset
Set condbf = New ADODB.Connection

Dim strCnnImport As String
strCnnImport = "Provider=MSDASQL.1;Persist Security Info=False;Data Source=dBASE Files;Initial Catalog=" & App.Path
condbf.ConnectionString = strCnnImport
rsdbf.Open "select * from import", condbf, adOpenKeyset, adLockOptimistic
'上行有错。

rsdbf.addnew
....
rsdbf.update

loop
--------------------------
运行上面的代码,提示错误:
实时错误'3709'
the Connection cannot be used to perform this operation.
Tt is either closed or invalid in this context.
--------------------------

正确的连接方法要怎么写?对不同的版本dbf文件,是否有不同的写法??
最好是完全用代码的方法来写!因为这具import.dbf文件是临时生成的,还有,它可能是dbfIII文件,(但也可能不是这个版本,我不能决定!)











...全文
114 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
zjcxc 2003-10-16
  • 打赏
  • 举报
回复
'你的应该修改为:

do while ....
FileCopy App.Path & "\EXPVCH.STD", App.Path & "\Import.dbf" '权限07
Dim rsdbf As ADODB.Recordset
Dim condbf As ADODB.Connection
Set rsdbf = New ADODB.Recordset
Set condbf = New ADODB.Connection

Dim strCnnImport As String
strCnnImport = "Provider=MSDASQL.1;Persist Security Info=False;Extended Properties=""DSN=Visual FoxPro Tables;UID=;SourceType=DBF" & _
";SourceDB=" & App.Path
condbf.ConnectionString = strCnnImport
rsdbf.Open "select * from [import.dbf]", condbf, adOpenKeyset, adLockOptimistic
zjcxc 2003-10-16
  • 打赏
  • 举报
回复
'用下面的连接方法就行了.

Sub fox()
Dim iRe As ADODB.Recordset
Dim iConc As String

iConc = "Provider=MSDASQL.1;Persist Security Info=False;Extended Properties=""DSN=Visual FoxPro Tables;UID=;SourceType=DBF" & _
";SourceDB=f:\My Documents"""

Set iRe = New ADODB.Recordset
iRe.Open "select * from [aa.dbf]", iConc, adOpenKeyset, adLockOptimistic

MsgBox iRe.Fields(0)
End Sub
lxcc 2003-10-16
  • 打赏
  • 举报
回复
最好自己建立DSN

控制面板……》管理工具……》数据源(ODBC)……》系统DSN……》Driver ... for DBF()

1,216

社区成员

发帖
与我相关
我的任务
社区描述
VB 数据库(包含打印,安装,报表)
社区管理员
  • 数据库(包含打印,安装,报表)社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧