计算机 2005-9-9 07:59
在VB里面如何打开.dbf库啊
在VB里面如何打开.dbf库啊,请你写一段代码,好吗
zhouln2008 2007-9-17 09:56
Private Sub ConnDBF()
'连接数据库
Dim StrConnect As String
Dim myexit As Long
StrConnect = "PROVIDER=MSDASQL;DRIVER={Microsoft Visual Foxpro Driver};SourceDB=C:\RepTasks2006\2006年度北京市部门决算.TSK\PARA;SourceType=DBF"
If ConnectDbase(StrConnect) Then
'myexit = MsgBox("数据库连接成功! ", vbOKOnly, "连接提示:")
Exit Sub
Else
myexit = MsgBox("数据库连接失败!请检查连接设置信息。", vbOKOnly, "错误提示:")
Unload Me
End If
End Sub
Public Function ConnectDbase(StrConnect As String) As Boolean
On Error GoTo ErrHandle
'cndbase.ConnectionString = "PROVIDER=MSDASQL;DRIVER={Microsoft Visual Foxpro Driver};SourceDB=E:\久其格式\;SourceType=DBF"
cndbase.ConnectionString = StrConnect
cndbase.Open
cndbase.CursorLocation = adUseClient
ConnectDbase = True
Exit Function
ErrHandle:
ConnectDbase = False
End Function
'调用数据
rsdbase.Open "Select index,bbbs,bblx,zbt,bbbh From BBBT", cndbase, adOpenDynamic, adLockPessimistic, adCmdText