如何在VB中用ADO读取DBF文件中的数据?
答案:1 悬赏:50 手机版
解决时间 2021-02-10 02:01
- 提问者网友:蓝琪梦莎
- 2021-02-09 05:36
最好能有连接,打开的方法,附例子最好.
最佳答案
- 五星知识达人网友:从此江山别
- 2021-02-09 06:10
Public DBFcon As New ADODB.Connection
'打开DBF文件
Public Function OpenDBF(DirPath As String) As Boolean
On Error GoTo err
DBFcon.open "Provider=MSDASQL.1;Driver=Microsoft Visual Foxpro Driver;SourceDB=" + DirPath + ";SourceType=DBF; "
OpenDBF = True
Exit Function
err:
OpenDBF = False
MsgBox err.Description
End Function
‘关闭dbf文件
Public Sub CloseDBF()
If DBFcon.state = adStateOpen Then DBFcon.Close
End Sub
’执行select ,update,delete 操作
Public Function ExeDBF(sql As String, rs As ADODB.Recordset) As Boolean
On Error GoTo err
rs.open sql, DBFcon, adOpenKeyset, adLockOptimistic
ExeDBF = True
Exit Function
err:
ExeDBF = False
End Function
'打开DBF文件
Public Function OpenDBF(DirPath As String) As Boolean
On Error GoTo err
DBFcon.open "Provider=MSDASQL.1;Driver=Microsoft Visual Foxpro Driver;SourceDB=" + DirPath + ";SourceType=DBF; "
OpenDBF = True
Exit Function
err:
OpenDBF = False
MsgBox err.Description
End Function
‘关闭dbf文件
Public Sub CloseDBF()
If DBFcon.state = adStateOpen Then DBFcon.Close
End Sub
’执行select ,update,delete 操作
Public Function ExeDBF(sql As String, rs As ADODB.Recordset) As Boolean
On Error GoTo err
rs.open sql, DBFcon, adOpenKeyset, adLockOptimistic
ExeDBF = True
Exit Function
err:
ExeDBF = False
End Function
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯