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

📄 frmquery.frm

📁 通过实现数据绑定的功能
💻 FRM
字号:
VERSION 5.00
Object = "{67397AA1-7FB1-11D0-B148-00A0C922E820}#6.0#0"; "MSADODC.OCX"
Object = "{CDE57A40-8B86-11D0-B3C6-00A0C90AEA82}#1.0#0"; "MSDATGRD.OCX"
Begin VB.Form frmQuery 
   BorderStyle     =   3  'Fixed Dialog
   Caption         =   "产品查询"
   ClientHeight    =   6840
   ClientLeft      =   45
   ClientTop       =   330
   ClientWidth     =   8610
   LinkTopic       =   "Form2"
   MaxButton       =   0   'False
   MDIChild        =   -1  'True
   MinButton       =   0   'False
   ScaleHeight     =   6840
   ScaleWidth      =   8610
   ShowInTaskbar   =   0   'False
   Begin VB.Frame Frame2 
      Caption         =   "产品查询"
      Height          =   1095
      Left            =   240
      TabIndex        =   2
      Top             =   360
      Width           =   7815
      Begin VB.TextBox txtName 
         Height          =   495
         Left            =   1680
         TabIndex        =   6
         Top             =   360
         Width           =   1815
      End
      Begin VB.CommandButton cmdQuery 
         Caption         =   "查询"
         Default         =   -1  'True
         Height          =   495
         Left            =   4080
         TabIndex        =   5
         Top             =   360
         Width           =   975
      End
      Begin VB.CommandButton cmdClose 
         Caption         =   "关闭"
         Height          =   495
         Left            =   6480
         TabIndex        =   4
         Top             =   360
         Width           =   975
      End
      Begin VB.CommandButton cmdClear 
         Caption         =   "清空"
         Height          =   495
         Left            =   5280
         TabIndex        =   3
         Top             =   360
         Width           =   975
      End
      Begin VB.Label Label1 
         Caption         =   "产品名称"
         Height          =   375
         Left            =   240
         TabIndex        =   7
         Top             =   480
         Width           =   1095
      End
   End
   Begin VB.Frame Frame1 
      Caption         =   "查询结果"
      Height          =   3855
      Left            =   240
      TabIndex        =   0
      Top             =   1680
      Width           =   7815
      Begin MSDataGridLib.DataGrid DataGrid1 
         Bindings        =   "frmQuery.frx":0000
         Height          =   3255
         Left            =   240
         TabIndex        =   1
         Top             =   360
         Width           =   7335
         _ExtentX        =   12938
         _ExtentY        =   5741
         _Version        =   393216
         HeadLines       =   1
         RowHeight       =   15
         BeginProperty HeadFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "宋体"
            Size            =   9
            Charset         =   134
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "宋体"
            Size            =   9
            Charset         =   134
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ColumnCount     =   2
         BeginProperty Column00 
            DataField       =   ""
            Caption         =   ""
            BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
               Type            =   0
               Format          =   ""
               HaveTrueFalseNull=   0
               FirstDayOfWeek  =   0
               FirstWeekOfYear =   0
               LCID            =   2052
               SubFormatType   =   0
            EndProperty
         EndProperty
         BeginProperty Column01 
            DataField       =   ""
            Caption         =   ""
            BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
               Type            =   0
               Format          =   ""
               HaveTrueFalseNull=   0
               FirstDayOfWeek  =   0
               FirstWeekOfYear =   0
               LCID            =   2052
               SubFormatType   =   0
            EndProperty
         EndProperty
         SplitCount      =   1
         BeginProperty Split0 
            BeginProperty Column00 
            EndProperty
            BeginProperty Column01 
            EndProperty
         EndProperty
      End
   End
   Begin MSAdodcLib.Adodc Adodc1 
      Height          =   495
      Left            =   240
      Top             =   5760
      Width           =   7815
      _ExtentX        =   13785
      _ExtentY        =   873
      ConnectMode     =   0
      CursorLocation  =   3
      IsolationLevel  =   -1
      ConnectionTimeout=   15
      CommandTimeout  =   30
      CursorType      =   3
      LockType        =   3
      CommandType     =   8
      CursorOptions   =   0
      CacheSize       =   50
      MaxRecords      =   0
      BOFAction       =   0
      EOFAction       =   0
      ConnectStringType=   1
      Appearance      =   1
      BackColor       =   -2147483643
      ForeColor       =   -2147483640
      Orientation     =   0
      Enabled         =   -1
      Connect         =   ""
      OLEDBString     =   ""
      OLEDBFile       =   ""
      DataSourceName  =   ""
      OtherAttributes =   ""
      UserName        =   ""
      Password        =   ""
      RecordSource    =   ""
      Caption         =   ""
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "宋体"
         Size            =   9
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      _Version        =   393216
   End
End
Attribute VB_Name = "frmQuery"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub cmdClear_Click()
    '清空查询条件
    txtName.Text = ""
    '设置鼠标焦点
    txtName.SetFocus
End Sub

Private Sub cmdQuery_Click()
    Dim strSQL As String
    '查询不能为空
    If Trim(txtName.Text) = "" Then
        MsgBox "查询姓名不能为空!", vbOKOnly + vbExclamation, "警告!"
        '设置鼠标焦点
        txtName.SetFocus
        Exit Sub
    End If
    '获得产品名称的查询条件
    strSQL = "Select * From product Where 名称 like " _
     + "'" + Replace(Trim(txtName.Text), "'", "''", 1) + "%'"
    Adodc1.ConnectionString = ConnectString
    '设置Adodc1的命令类型和记录源
    Adodc1.CommandType = adCmdText
    Adodc1.RecordSource = strSQL
    '刷新Adodc1
    Adodc1.Refresh
End Sub

Private Sub cmdClose_Click()
    '释放窗体本身
    Unload Me
End Sub

Private Sub Form_Load()

'设置Adodc1的连接字符串和记录源
'Adodc1.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + App.Path + "\product.mdb;Persist Security Info=False"
'Adodc1.RecordSource = "Select * From product "
'将DataGrid1和Adodc1绑定
'设置DataGrid1的数据源
'Set DataGrid1.DataSource = Adodc1
End Sub

⌨️ 快捷键说明

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