打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
Form1.frm vb sqlite operation
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
本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
【热】打开小程序,算一算2024你的财运
VB中操作EXECL表格(不使用AOD、DAO等)
VB怎么移动鼠标到指定位置
STM32正弦波逆变器设计资料 含SPWM数据生成软件VB源码+PCB+原理图等
在VB中创建和使用动态数组控件的方法总结
Visual Basic中文本框处理技巧集萃
vb 简单彩色进度条代码 |VB 网|VB 视频教程|VB编程入门网
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服