📄 modexample1.bas
字号:
Attribute VB_Name = "modExample1"
Sub main()
Dim DB As New RAccessDB
Dim RS As RAccessRS
Dim b As Boolean
b = DB.OpenConnection("192.168.1.125", "DSN=testmdb;DRIVER={Microsoft Access Driver (*.mdb)};UID=admin;PWD=;")
If Not b Then
MsgBox DB.GetLastError
Exit Sub
End If
Set RS = DB.OpenResultset("SELECT * FROM zdxx")
If RS Is Nothing Then
MsgBox "记录集合打开错误!" & DB.GetLastError
Exit Sub
End If
If RS.IsError() Then
MsgBox RS.GetLastError
Exit Sub
End If
Dim nFieldsCount As Long
nFieldsCount = RS.GetFieldsCount
Do Until RS.EOF
s = ""
For i = 0 To nFieldsCount - 1
s = s & RS.GetFieldValue(i) & ","
Next
Debug.Print s
RS.MoveNext
Loop
Set RS = Nothing
Dim nRecordAffected As Long
b = DB.Execute("INSERT into zdxx(zdxx,lkd,tabstop) values('测试内容','130','1') ", nRecordAffected)
'b = DB.Execute("delete * from zdxx where zdxx='测试内容'", nRecordAffected)
If b Then
MsgBox nRecordAffected
End If
DB.CloseConnection
Set DB = Nothing
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -