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

📄 form5.frm

📁 很好的运行在vb6.0与sqlserver上,保证能够运行通过
💻 FRM
字号:
VERSION 5.00
Object = "{5E9E78A0-531B-11CF-91F6-C2863C385E30}#1.0#0"; "MSFLXGRD.OCX"
Begin VB.Form Form5 
   Caption         =   "Form5"
   ClientHeight    =   6810
   ClientLeft      =   60
   ClientTop       =   510
   ClientWidth     =   6930
   LinkTopic       =   "Form5"
   ScaleHeight     =   6810
   ScaleWidth      =   6930
   StartUpPosition =   3  '窗口缺省
   Begin VB.CommandButton Command3 
      Caption         =   "删除"
      Height          =   495
      Left            =   4920
      TabIndex        =   9
      Top             =   6000
      Width           =   1335
   End
   Begin VB.CommandButton Command2 
      Caption         =   "返回"
      Height          =   495
      Left            =   4800
      TabIndex        =   8
      Top             =   1440
      Width           =   1095
   End
   Begin MSFlexGridLib.MSFlexGrid MSFlexGrid1 
      Height          =   2895
      Left            =   120
      TabIndex        =   1
      Top             =   2880
      Width           =   6015
      _ExtentX        =   10610
      _ExtentY        =   5106
      _Version        =   393216
   End
   Begin VB.Frame Frame1 
      Caption         =   "查询删除(两者选择一个或两个都可)"
      Height          =   1935
      Left            =   120
      TabIndex        =   0
      Top             =   240
      Width           =   6255
      Begin VB.CommandButton Command1 
         Caption         =   "搜索"
         Height          =   495
         Left            =   4680
         TabIndex        =   6
         Top             =   360
         Width           =   975
      End
      Begin VB.TextBox Text2 
         Height          =   495
         Left            =   2280
         TabIndex        =   5
         Top             =   1200
         Width           =   1455
      End
      Begin VB.TextBox Text1 
         Height          =   495
         Left            =   120
         TabIndex        =   4
         Top             =   1200
         Width           =   1335
      End
      Begin VB.Label Label2 
         Caption         =   "学生学号"
         Height          =   615
         Left            =   2520
         TabIndex        =   3
         Top             =   480
         Width           =   1335
      End
      Begin VB.Label Label1 
         Caption         =   "学生姓名"
         Height          =   615
         Left            =   120
         TabIndex        =   2
         Top             =   480
         Width           =   1095
      End
   End
   Begin VB.Label Label4 
      Caption         =   "从上面显示中选一条删除"
      Height          =   495
      Left            =   2400
      TabIndex        =   10
      Top             =   6120
      Width           =   2295
   End
   Begin VB.Label Label3 
      Caption         =   "显示满足条件的信息"
      Height          =   495
      Left            =   120
      TabIndex        =   7
      Top             =   2400
      Width           =   3855
   End
End
Attribute VB_Name = "Form5"
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 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
Label3.Caption = "现在数据库中的所有信息如下:  "

End Sub

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

Private Sub Command3_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
With MSFlexGrid1
  If MsgBox("你是否要删除当前记录" + .TextMatrix(.Row, 0), vbYesNo, "提示") = vbYes Then
     txtsql = "delete from student where 学生学号='" + .TextMatrix(.Row, 1) + "'"
     cn.Execute txtsql
     MsgBox "记录已经被删除", , "提示"
  End If
End With
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

⌨️ 快捷键说明

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