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

📄 form3.frm

📁 很好的运行在vb6.0与sqlserver上,保证能够运行通过
💻 FRM
字号:
VERSION 5.00
Object = "{5E9E78A0-531B-11CF-91F6-C2863C385E30}#1.0#0"; "MSFLXGRD.OCX"
Begin VB.Form Form3 
   Caption         =   "Form3"
   ClientHeight    =   7170
   ClientLeft      =   60
   ClientTop       =   510
   ClientWidth     =   10335
   LinkTopic       =   "Form3"
   LockControls    =   -1  'True
   ScaleHeight     =   7170
   ScaleWidth      =   10335
   StartUpPosition =   3  '窗口缺省
   Begin VB.CommandButton Command3 
      Caption         =   "返回"
      Height          =   615
      Left            =   8280
      TabIndex        =   21
      Top             =   6240
      Width           =   1215
   End
   Begin VB.CommandButton Command2 
      Caption         =   "确定"
      Height          =   615
      Left            =   6600
      TabIndex        =   20
      Top             =   6240
      Width           =   1215
   End
   Begin MSFlexGridLib.MSFlexGrid MSFlexGrid1 
      Height          =   4455
      Left            =   120
      TabIndex        =   7
      Top             =   2520
      Width           =   6015
      _ExtentX        =   10610
      _ExtentY        =   7858
      _Version        =   393216
   End
   Begin VB.Frame Frame2 
      Caption         =   "修改输入"
      Height          =   5535
      Left            =   6240
      TabIndex        =   1
      Top             =   240
      Width           =   3975
      Begin VB.TextBox Text8 
         Height          =   495
         Left            =   1440
         TabIndex        =   19
         Top             =   4320
         Width           =   1935
      End
      Begin VB.TextBox Text7 
         Height          =   495
         Left            =   1440
         TabIndex        =   18
         Top             =   3480
         Width           =   1335
      End
      Begin VB.TextBox Text6 
         Height          =   495
         Left            =   1440
         TabIndex        =   17
         Top             =   2640
         Width           =   1095
      End
      Begin VB.TextBox Text5 
         Height          =   495
         Left            =   1440
         TabIndex        =   16
         Top             =   1800
         Width           =   975
      End
      Begin VB.TextBox Text4 
         Height          =   495
         Left            =   1440
         TabIndex        =   15
         Top             =   1080
         Width           =   1815
      End
      Begin VB.TextBox Text3 
         Height          =   495
         Left            =   1440
         TabIndex        =   14
         Top             =   240
         Width           =   1815
      End
      Begin VB.Label Label8 
         Caption         =   "电话"
         Height          =   615
         Left            =   120
         TabIndex        =   13
         Top             =   4440
         Width           =   1215
      End
      Begin VB.Label Label7 
         Caption         =   "所属院系"
         Height          =   615
         Left            =   120
         TabIndex        =   12
         Top             =   3480
         Width           =   1215
      End
      Begin VB.Label Label6 
         Caption         =   "年龄"
         Height          =   495
         Left            =   120
         TabIndex        =   11
         Top             =   2760
         Width           =   1215
      End
      Begin VB.Label Label5 
         Caption         =   "性别"
         Height          =   615
         Left            =   120
         TabIndex        =   10
         Top             =   1920
         Width           =   1215
      End
      Begin VB.Label Label4 
         Caption         =   "学生学号(若要修改输入则必添)"
         Height          =   615
         Left            =   120
         TabIndex        =   9
         Top             =   1080
         Width           =   1215
      End
      Begin VB.Label Label3 
         Caption         =   "学生姓名"
         Height          =   495
         Left            =   120
         TabIndex        =   8
         Top             =   360
         Width           =   1215
      End
   End
   Begin VB.Frame Frame1 
      Caption         =   "查询输入(两者选择一个或两个都可)"
      Height          =   1935
      Left            =   240
      TabIndex        =   0
      Top             =   240
      Width           =   5775
      Begin VB.CommandButton Command1 
         Caption         =   "查询"
         Height          =   495
         Left            =   4800
         TabIndex        =   6
         Top             =   1200
         Width           =   855
      End
      Begin VB.TextBox Text2 
         Height          =   495
         Left            =   2400
         TabIndex        =   5
         Top             =   1080
         Width           =   1455
      End
      Begin VB.TextBox Text1 
         Height          =   495
         Left            =   360
         TabIndex        =   4
         Top             =   1080
         Width           =   1215
      End
      Begin VB.Label Label2 
         Caption         =   "学生学号"
         Height          =   495
         Left            =   2400
         TabIndex        =   3
         Top             =   480
         Width           =   1335
      End
      Begin VB.Label Label1 
         Caption         =   "学生姓名"
         Height          =   495
         Left            =   360
         TabIndex        =   2
         Top             =   480
         Width           =   1215
      End
   End
End
Attribute VB_Name = "Form3"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False

Private Sub Command1_Click()
Dim str As String
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 student"
  Else
    txtsql = "select * from student where 学生学号='" + Text2.Text + "'"
  End If
Else
 If Text2.Text = "" Then
   txtsql = "select * from student where 学生姓名='" + Text1.Text + "'"
 Else
   txtsql = "select * from student 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()
Set cn = New ADODB.Connection
cn.ConnectionString = "driver={sql server};server=fu;uid=sa;pwd=;database=sinformation"
cn.Open
Set rs = New ADODB.Recordset
txtsql = "select * from student where 学生学号='" + Text4.Text + "'"
rs.Open txtsql, cn, adOpenDynamic, adLockOptimistic
rs.Fields(0) = Text3.Text
rs.Fields(1) = Text4.Text
rs.Fields(2) = Text5.Text
rs.Fields(3) = Text6.Text
rs.Fields(4) = Text7.Text
rs.Fields(5) = Text8.Text
rs.Update
rs.Close
MsgBox "修改成功", , "提示"
Text3.Text = ""
Text4.Text = ""
Text5.Text = ""
Text6.Text = ""
Text7.Text = ""
Text8.Text = ""
txtsql = "select * from student"
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 Command3_Click()
Form3.Hide
Form1.Show

End Sub

⌨️ 快捷键说明

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