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

📄 查询.frm

📁 针对数据库做简单的查询字段
💻 FRM
字号:
VERSION 5.00
Object = "{5E9E78A0-531B-11CF-91F6-C2863C385E30}#1.0#0"; "MSFLXGRD.OCX"
Object = "{67397AA1-7FB1-11D0-B148-00A0C922E820}#6.0#0"; "MSADODC.OCX"
Begin VB.Form 查询 
   Caption         =   "查询"
   ClientHeight    =   7770
   ClientLeft      =   60
   ClientTop       =   420
   ClientWidth     =   8820
   LinkTopic       =   "Form1"
   ScaleHeight     =   7770
   ScaleWidth      =   8820
   StartUpPosition =   3  'Windows Default
   Begin VB.CommandButton Command2 
      Caption         =   "Command2"
      Height          =   615
      Left            =   5760
      TabIndex        =   6
      Top             =   6240
      Width           =   1815
   End
   Begin VB.TextBox Text2 
      Height          =   615
      Left            =   6720
      TabIndex        =   3
      Top             =   1080
      Width           =   1455
   End
   Begin MSAdodcLib.Adodc Adodc1 
      Height          =   375
      Left            =   840
      Top             =   5520
      Visible         =   0   'False
      Width           =   1200
      _ExtentX        =   2117
      _ExtentY        =   661
      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         =   "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=F:\tv.mdb;Persist Security Info=False"
      OLEDBString     =   "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=F:\tv.mdb;Persist Security Info=False"
      OLEDBFile       =   ""
      DataSourceName  =   ""
      OtherAttributes =   ""
      UserName        =   ""
      Password        =   ""
      RecordSource    =   ""
      Caption         =   "Adodc1"
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      _Version        =   393216
   End
   Begin MSFlexGridLib.MSFlexGrid MSFlexGrid1 
      Height          =   2415
      Left            =   960
      TabIndex        =   2
      Top             =   2520
      Width           =   6615
      _ExtentX        =   11668
      _ExtentY        =   4260
      _Version        =   393216
      Cols            =   7
   End
   Begin VB.CommandButton Command1 
      Caption         =   "查询"
      Height          =   615
      Left            =   3840
      TabIndex        =   1
      Top             =   1080
      Width           =   1215
   End
   Begin VB.TextBox Text1 
      Height          =   495
      Left            =   1680
      TabIndex        =   0
      Top             =   1080
      Width           =   1575
   End
   Begin VB.Label Label2 
      Caption         =   "人数"
      Height          =   375
      Left            =   5400
      TabIndex        =   5
      Top             =   1200
      Width           =   1095
   End
   Begin VB.Label Label1 
      Caption         =   "节目名称"
      Height          =   495
      Left            =   240
      TabIndex        =   4
      Top             =   1080
      Width           =   1215
   End
End
Attribute VB_Name = "查询"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Public cn As ADODB.Connection          '定义连接对象
Public rs As ADODB.Recordset           '定义记录集对象

Private Sub Command1_Click()


SQL = "select * from 机顶盒回传信息 where 频道信息 =" + "'" + Text1 + "'" + " order by 人员编号 asc;"
 
 Set cn = New ADODB.Connection        '创建新的连接对象

    cn.Open "DSN=tv"                  '打开数据源  dsn:Data Source Name
    
    

Set rs = cn.Execute(SQL)    'Execte:执行指定的查询、SQL语句,存储过程或特定提供者的文本等内容
Dim j As Integer
Dim n As Integer
j = 1
n = 0


If rs.EOF = True Then
    MsgBox "库中无此记录!", vbInformation + vbOKOnly, "错误信息"
     Text1 = ""
End If


While rs.EOF = False
   MSFlexGrid1.Rows = j + 1
   For i = 0 To 4
    If i = 3 Then
       MSFlexGrid1.TextMatrix(j, i + 1) = ""
        Else
         If IsNull(rs.Fields(i)) Then

          MSFlexGrid1.TextMatrix(j, i + 1) = ""

         Else

         MSFlexGrid1.TextMatrix(j, i + 1) = rs.Fields(i)
        End If
     End If
    Next i
j = j + 1
n = n + 1

rs.MoveNext
Text2.Text = n
Wend
End Sub

Private Sub Command2_Click()

Dim i As Integer, j As Integer
Dim newxls As Excel.Application
Dim newbook As Excel.Workbook
Dim newsheet As Excel.Worksheet
Set newxls = CreateObject("excel.application")
newxls.Visible = True
Set newbook = newxls.Workbooks.Add
Set newsheet = newbook.Worksheets(1)
For i = 0 To MSFlexGrid1.Rows - 1
For j = 0 To MSFlexGrid1.Cols - 1
    newsheet.Cells(i + 1, j + 1) = MSFlexGrid1.TextMatrix(i, j)
 Next j
Next i

End Sub



Private Sub Form_Load()                              ' 在第一行添加标题项

    MSFlexGrid1.TextMatrix(0, 1) = "自动编号"
    MSFlexGrid1.TextMatrix(0, 2) = "频道信息"
    MSFlexGrid1.TextMatrix(0, 3) = "人员编号"
    MSFlexGrid1.TextMatrix(0, 4) = "收看开始时间"
    MSFlexGrid1.TextMatrix(0, 5) = "收看结束时间"
    
    
    
    
    MSFlexGrid1.ColWidth(0) = 1000                   '设置列宽
    MSFlexGrid1.ColWidth(1) = 1000
    MSFlexGrid1.ColWidth(2) = 1000
    MSFlexGrid1.ColWidth(3) = 1000
    MSFlexGrid1.ColWidth(4) = 2000
    MSFlexGrid1.ColWidth(5) = 2000
    
    
End Sub

⌨️ 快捷键说明

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