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

📄 form6.frm

📁 很好的运行在vb6.0与sqlserver上,保证能够运行通过
💻 FRM
字号:
VERSION 5.00
Object = "{5E9E78A0-531B-11CF-91F6-C2863C385E30}#1.0#0"; "MSFLXGRD.OCX"
Begin VB.Form Form6 
   Caption         =   "Form6"
   ClientHeight    =   6180
   ClientLeft      =   60
   ClientTop       =   510
   ClientWidth     =   6555
   LinkTopic       =   "Form6"
   ScaleHeight     =   6180
   ScaleWidth      =   6555
   StartUpPosition =   3  '窗口缺省
   Begin VB.CommandButton Command2 
      Caption         =   "返回"
      Height          =   495
      Left            =   5160
      TabIndex        =   7
      Top             =   5400
      Width           =   1215
   End
   Begin MSFlexGridLib.MSFlexGrid MSFlexGrid1 
      Height          =   2895
      Left            =   240
      TabIndex        =   6
      Top             =   2280
      Width           =   5535
      _ExtentX        =   9763
      _ExtentY        =   5106
      _Version        =   393216
   End
   Begin VB.Frame Frame1 
      Caption         =   "查询条件(两者选择一个或两个都可)"
      Height          =   1935
      Left            =   120
      TabIndex        =   0
      Top             =   120
      Width           =   5535
      Begin VB.CommandButton Command1 
         Caption         =   "查询"
         Height          =   495
         Left            =   4440
         TabIndex        =   5
         Top             =   1200
         Width           =   975
      End
      Begin VB.TextBox Text2 
         Height          =   495
         Left            =   2400
         TabIndex        =   4
         Top             =   1080
         Width           =   1335
      End
      Begin VB.TextBox Text1 
         Height          =   495
         Left            =   240
         TabIndex        =   3
         Top             =   1080
         Width           =   1335
      End
      Begin VB.Label Label2 
         Caption         =   "学生学号"
         Height          =   495
         Left            =   2400
         TabIndex        =   2
         Top             =   600
         Width           =   1815
      End
      Begin VB.Label Label1 
         Caption         =   "学生姓名"
         Height          =   495
         Left            =   240
         TabIndex        =   1
         Top             =   600
         Width           =   1215
      End
   End
End
Attribute VB_Name = "Form6"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub Command1_Click()
Dim i As Integer
Set cn = New ADODB.Connection
cn.ConnectionString = "driver={sql server};server=fu;uid=sa;pwd=;database=sinformation"
cn.Open
Set rs = New ADODB.Recordset
If Text1.Text = "" Then
  If Text2.Text = "" Then
    txtsql = "select * from grade"
  Else
    txtsql = "select * from grade where 学生学号='" + Text2.Text + "'"
  End If
Else
 If Text2.Text = "" Then
   txtsql = "select * from grade where 学生姓名='" + Text1.Text + "'"
 Else
   txtsql = "select * from grade where 学生姓名='" + Text1.Text + "' and 学生学号='" + Text2.Text + "'"
End If
End If
rs.Open txtsql, cn, adOpenDynamic, adLockOptimistic
If rs.EOF Then
  MsgBox "没有找到任何相关记录", , "提示"
  With MSFlexGrid1
     .Cols = 0
     .Rows = 0
  End With
Else
   With MSFlexGrid1
      .Cols = 6
      .Rows = 1
      For i = 0 To 5
        .TextMatrix(0, i) = rs.Fields(i).Name
      Next i
      While Not rs.EOF
        .Rows = .Rows + 1
        For i = 0 To 5
          .TextMatrix(.Rows - 1, i) = rs.Fields(i)
        Next i
        rs.movenext
      Wend
    End With
End If
End Sub

Private Sub Command2_Click()
Form6.Hide
Form1.Show
End Sub

⌨️ 快捷键说明

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