VERSION 5.00
Begin VB.
Form
Form1
Caption =
"VB Sqlite使用示例"
ClientHeight = 4050
ClientLeft = 60
ClientTop = 450
ClientWidth = 5940
LinkTopic =
"Form1"
ScaleHeight = 4050
ScaleWidth = 5940
StartUpPosition = 3
'窗口缺省
Begin VB.TextBox Text5
Height = 375
Left
= 4320
TabIndex = 9
Text
=
"15555555555"
Top = 2160
Width = 1455
End
Begin VB.TextBox Text4
Height = 375
Left
= 3360
TabIndex = 8
Text
=
"张三"
Top = 2160
Width = 855
End
Begin VB.CommandButton Command4
Caption =
"修改记录"
Height = 375
Left
= 3360
TabIndex = 7
Top = 2640
Width = 975
End
Begin VB.TextBox Text3
Height = 375
Left
= 3360
TabIndex = 6
Text
=
"张三"
Top = 3600
Width = 855
End
Begin VB.CommandButton Command3
Caption =
"删除"
Height = 375
Left
= 4320
TabIndex = 5
Top = 3600
Width = 975
End
Begin VB.TextBox Text2
Height = 375
Left
= 4320
TabIndex = 4
Text
=
"13800138000"
Top = 840
Width = 1455
End
Begin VB.TextBox Text1
Height = 375
Left
= 3360
TabIndex = 3
Text
=
"张三"
Top = 840
Width = 855
End
Begin VB.ListBox List1
Height = 3840
Left
= 120
TabIndex = 2
Top = 120
Width = 3135
End
Begin VB.CommandButton Command2
Caption =
"添加记录"
Height = 375
Left
= 3360
TabIndex = 1
Top = 1320
Width = 975
End
Begin VB.CommandButton Command1
Caption =
"读取记录"
Height = 375
Left
= 3360
TabIndex = 0
Top = 120
Width = 975
End
End
Attribute VB_Name =
"Form1"
Attribute VB_GlobalNameSpace =
False
Attribute VB_Creatable =
False
Attribute VB_PredeclaredId =
True
Attribute VB_Exposed =
False
'Download by http://www.NewXing.com
Private
Conn
As
New
LiteConnection
Private
Sub
Form_Load()
Conn.
Open
App.Path &
"\db1.db"
'打开数据库
Command1_Click
End
Sub
'//读取按钮
Private
Sub
Command1_Click()
List1.Clear
Dim
Rs
As
New
LiteStatement
'sqlite记录集
'//读取数据集
Set
Rs = Conn.Prepare(
"Select * from Table1"
)
Rs.
Step
'//默认初始游标在所有数据之前,所以要推至第一条数据
'//如果有记录
If
Not
Rs.Done
Then
'//循环读取记录
Do
While
Not
Rs.Done
'//显示记录
List1.AddItem Rs.ColumnValue(
"name"
) &
" "
& Rs.ColumnValue(
"phone"
)
'//游标下移下条数据
Rs.
Step
Loop
End
If
Rs.
Close
Set
Rs =
Nothing
End
Sub
'//增加按钮
Private
Sub
Command2_Click()
Conn.
Execute
"insert into Table1(name,phone) values('"
& Text1.
Text
&
"','"
& Text2.
Text
&
"')"
Command1_Click
End
Sub
'//删除按钮
Private
Sub
Command3_Click()
Conn.
Execute
(
"delete from Table1 where name='"
& Text3.
Text
&
"'"
)
Command1_Click
End
Sub
'//修改按钮
Private
Sub
Command4_Click()
Conn.
Execute
"update Table1 set phone='"
& Text5.
Text
&
"' where name='"
& Text4.
Text
&
"'"
Command1_Click
End
Sub
联系客服