数据表:
界面:
Private Conn As New LiteConnection ''引用sqlite3.dll
Private Sub Command3_Click()
Conn.Execute "DELETE FROM st_data WHERE 网页检索码 ='" & Text3.Text & "'"
Command1_Click
End Sub
Private Sub Form_Load()
If zc_dll = True Then
Conn.Open App.Path & "\vbxym.db" ''打开数据库
Command1_Click
Else
MsgBox "控件未注册!"
End
End If
End Sub
Private Sub Command1_Click()
List1.Clear
Dim Rs As New LiteStatement 'sqlite记录集
Set Rs = Conn.Prepare("Select * from st_data") '读取数据集
Rs.Step '默认初始游标在所有数据之前,所以要推至第一条数据
If Not Rs.Done Then
Do While Not Rs.Done '循环读取记录
List1.AddItem Rs.ColumnValue("站点名称") & vbTab & Rs.ColumnValue("站点拼音") '显示记录
Rs.Step '游标下移下条数据
Loop
End If
Rs.Close
Set Rs = Nothing
End Sub
Private Sub Command2_Click()
Conn.Execute "insert into st_data(站点简写,站点名称,网页检索码,站点拼音,拼音首字母) values('" & Text1.Text & "','" & Text2.Text & "','" & Text3.Text & "','" & Text4.Text & "','" & Text5.Text & "')"
Command1_Click
End Sub
Function zc_dll() As Boolean ''控件注册
On Error GoTo a
Dim sstr As String
sstr = "regsvr32 /s " & App.Path & "\sqlite3.dll"
Shell sstr, vbHide
zc_dll = True
Exit Function
a:
zc_dll = False
'MsgBox err.Description
End Function
Private Sub Form_Unload(Cancel As Integer)
On Error Resume Next
Shell "regsvr32 /u " & App.Path & "\sqlite3.dll", vbHide ''卸载控件
End Sub
连接地址:
https://www.lanzous.com/i4fwfxe
谢谢关注与支持