vb操作dbf 源代码


Dim CNN As New ADODB.Connection
Dim STRSQL As String

' 打开
Private SubForm_Load() SubForm_Load()
CNN.ConnectionString
="Driver={MicrosoftVisualFoxProDriver};SourceType=DBF;SourceDb=E:DBF"
CNN.Open

EndSub


' 创建
Private SubCommand1_Click() SubCommand1_Click()
CNN.CursorLocation
=adUseClient
STRSQL
="CREATETABLEE:DBFDEMO.DBF([IDA]CHAR(32),[NAME]CHAR(32))"
CNN.ExecuteSTRSQL
'CNN.Close
EndSub


' 添加
Private SubCommand2_Click() SubCommand2_Click()

STRSQL
="insertintodemo([ida],[NAME])values('1','sdf')"
CNN.ExecuteSTRSQL
EndSub


' 显示
Private SubCommand3_Click() SubCommand3_Click()
DimrsAsNewADODB.Recordset
STRSQL
="select*fromdemo"
Setrs=CNN.Execute(STRSQL)
IfNotrs.EOFThen
Text1.Text
=rs.Fields(1)
EndIf
EndSub


' 修改
Private SubCommand4_Click() SubCommand4_Click()
STRSQL
="updatedemosetname='好好'whereida='1'"
CNN.ExecuteSTRSQL
EndSub

你可能感兴趣的:(源代码)