⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 frmqueryreader.frm

📁 中小型图书馆管理系统开发
💻 FRM
字号:
VERSION 5.00
Begin VB.Form frmQueryReader 
   Caption         =   "读者查询"
   ClientHeight    =   2535
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   5775
   LinkTopic       =   "Form1"
   ScaleHeight     =   2535
   ScaleWidth      =   5775
   StartUpPosition =   3  'Windows Default
   Begin VB.Frame Frame2 
      BackColor       =   &H80000016&
      Caption         =   "读者信息"
      Height          =   1215
      Left            =   120
      TabIndex        =   5
      Top             =   1200
      Width           =   5535
      Begin VB.Label lblInfo 
         Caption         =   "Label7"
         Height          =   255
         Index           =   2
         Left            =   3360
         TabIndex        =   11
         Top             =   360
         Width           =   1575
      End
      Begin VB.Label Label6 
         Caption         =   "所在班级:"
         Height          =   255
         Left            =   2400
         TabIndex        =   10
         Top             =   360
         Width           =   975
      End
      Begin VB.Label lblInfo 
         Caption         =   "Label5"
         Height          =   255
         Index           =   1
         Left            =   960
         TabIndex        =   9
         Top             =   720
         Width           =   735
      End
      Begin VB.Label Label4 
         Caption         =   "年龄:"
         Height          =   255
         Left            =   360
         TabIndex        =   8
         Top             =   720
         Width           =   735
      End
      Begin VB.Label lblInfo 
         Caption         =   "Label3"
         Height          =   255
         Index           =   0
         Left            =   960
         TabIndex        =   7
         Top             =   360
         Width           =   1095
      End
      Begin VB.Label Label2 
         Caption         =   "姓名:"
         Height          =   255
         Left            =   360
         TabIndex        =   6
         Top             =   360
         Width           =   615
      End
   End
   Begin VB.Frame Frame1 
      Caption         =   "查询"
      Height          =   975
      Left            =   120
      TabIndex        =   0
      Top             =   120
      Width           =   5535
      Begin VB.CommandButton Command2 
         Caption         =   "返回(&C)"
         Height          =   375
         Left            =   4320
         TabIndex        =   4
         Top             =   360
         Width           =   975
      End
      Begin VB.CommandButton Command1 
         Caption         =   "查询(&Q)"
         Height          =   375
         Left            =   3240
         TabIndex        =   3
         Top             =   360
         Width           =   975
      End
      Begin VB.TextBox txtID 
         Height          =   405
         Left            =   1440
         TabIndex        =   2
         Text            =   "Text1"
         Top             =   360
         Width           =   1575
      End
      Begin VB.Label Label1 
         Caption         =   "读者ID:"
         Height          =   255
         Left            =   600
         TabIndex        =   1
         Top             =   360
         Width           =   855
      End
   End
End
Attribute VB_Name = "frmQueryReader"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub Command1_Click()
queryReader
End Sub

Private Sub Command2_Click()
Unload Me
End Sub

Private Sub Form_Load()
txtID = ""
lblInfo(0).Caption = ""
lblInfo(1).Caption = ""
lblInfo(2).Caption = ""
End Sub


Sub queryReader()
Dim conn As New ADODB.Connection
Dim cmd As New ADODB.Command
Dim rs As New ADODB.Recordset
Dim sql As String

Dim dbPath As String
Dim connStr As String

Dim i As Integer
Dim j As Integer
   
dbPath = App.Path + "\db\library.mdb"
connStr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & dbPath

'使用Connection对象与具体的数据库文件相连接
conn.Open connStr

If txtID.Text = "" Then
    MsgBox "查询条件不能为空,请重新输入查询条件!!", vbExclamation, "错误提示"
    txtID.SetFocus
    Exit Sub
End If
sql = "select * from readers where [id]=" & txtID.Text
'执行SQL语句,建立打开记录集
rs.Open sql, conn, adOpenKeyset, adLockOptimistic

If rs.RecordCount = 0 Then
    lblInfo(0).Caption = ""
    lblInfo(1).Caption = ""
    lblInfo(2).Caption = ""

    MsgBox "没有查找满足条件的数据!", vbExclamation, "提示"
   
Else
    lblInfo(0).Caption = rs.Fields("name")
    lblInfo(1).Caption = rs.Fields("age")
    lblInfo(2).Caption = rs.Fields("class")

End If

End Sub

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -