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

📄 form6.frm

📁 能实现数据库的查询,修改,实用于一些用户的要求,实现基本的数据库功能.
💻 FRM
字号:
VERSION 5.00
Begin VB.Form Form6 
   BackColor       =   &H0080FF80&
   Caption         =   "Form6"
   ClientHeight    =   3585
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   5685
   LinkTopic       =   "Form2"
   ScaleHeight     =   3585
   ScaleWidth      =   5685
   StartUpPosition =   2  '屏幕中心
   Begin VB.CommandButton Command3 
      Caption         =   "登陆"
      Height          =   375
      Left            =   960
      TabIndex        =   7
      Top             =   2880
      Width           =   855
   End
   Begin VB.CommandButton Command2 
      Caption         =   "取消"
      Height          =   375
      Left            =   2160
      TabIndex        =   5
      Top             =   2880
      Width           =   855
   End
   Begin VB.TextBox Text2 
      BeginProperty Font 
         Name            =   "华文中宋"
         Size            =   15
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   495
      Left            =   1560
      TabIndex        =   2
      Text            =   "请输入密码!"
      Top             =   1920
      Width           =   3015
   End
   Begin VB.TextBox Text1 
      BeginProperty Font 
         Name            =   "华文中宋"
         Size            =   15
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   495
      Left            =   1560
      TabIndex        =   1
      Text            =   "请输入用户名!"
      Top             =   1200
      Width           =   3015
   End
   Begin VB.Frame Frame1 
      BackColor       =   &H0080FF80&
      ForeColor       =   &H0080FF80&
      Height          =   1815
      Left            =   600
      TabIndex        =   0
      Top             =   840
      Width           =   4335
      Begin VB.Label Label2 
         BackStyle       =   0  'Transparent
         Caption         =   "密码"
         Height          =   375
         Left            =   240
         TabIndex        =   4
         Top             =   1200
         Width           =   1335
      End
      Begin VB.Label Label1 
         BackStyle       =   0  'Transparent
         Caption         =   "用户名"
         Height          =   615
         Left            =   120
         TabIndex        =   3
         Top             =   480
         Width           =   1215
      End
   End
   Begin VB.Label Label5 
      BackStyle       =   0  'Transparent
      Caption         =   "更改密码"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   9
         Charset         =   134
         Weight          =   400
         Underline       =   -1  'True
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   375
      Left            =   4320
      TabIndex        =   9
      Top             =   3000
      Width           =   855
   End
   Begin VB.Label Label4 
      BackStyle       =   0  'Transparent
      Caption         =   "注册"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   9
         Charset         =   134
         Weight          =   400
         Underline       =   -1  'True
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   375
      Left            =   3600
      TabIndex        =   8
      Top             =   3000
      Width           =   975
   End
   Begin VB.Label Label3 
      BackStyle       =   0  'Transparent
      Caption         =   "用户登陆"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   15.75
         Charset         =   134
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H00FF0000&
      Height          =   855
      Left            =   2040
      TabIndex        =   6
      Top             =   240
      Width           =   2055
   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 rect As New ADODB.Recordset          '定义记录集对象
    Dim txtsql As String
    
    '查询语句:查询人员表,判断口令和密码是正确。本例中用户名和口令已经预设
    txtsql = "select * from 用户 where 用户名='" & Trim(Text1.Text) & "'" & " and 密码='" & Trim(Text2.Text) & "'"
    rect.Open txtsql, conn
   
    If rect.EOF = True Then
            MsgBox "用户名或口令错误,继续登录", vbOKOnly + vbExclamation, "信息提示"
            rst.Close
            Text1.Text = ""
            Text2.Text = ""
            Text1.SetFocus
    Else
        rect.Close
        With Form1       '设置菜单有效
           '.mnuCklr.Enabled = True
           '.mnuRklr.Enabled = True
           '.mnuGgkc.Enabled = True
           '.mnuDhbg.Enabled = True
           '.mnuJcsj.Enabled = True
        End With
            
        Unload Me
    End If
End Sub


Private Sub Command2_Click()
 Unload Me
End Sub

Private Sub Command3_Click()

Dim conn As New ADODB.Connection    '定义公共的connection对象
 
conn.ConnectionString = "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=wei"
    conn.Open
  Dim sq As String
  Dim rs As New ADODB.Recordset
  If Trim(Text1.Text) = "" Then
      MsgBox "没有这个用户", vbOKOnly + vbExclamation, ""
      Text1.SetFocus
   Else
      
      
     
     sq = "select * from 用户 where 用户名='" & Text1.Text & "'"
     rs.Open sq, conn, adOpenKeyset, adLockBatchOptimistic
     If rs.EOF = ture Then
       MsgBox "没有这个用户", vbOKOnly + vbExclamation, ""
       Text1.SetFocus
    Else
      If Trim(rs.Fields(1)) = Trim(Text2.Text) Then
      用户名 = Text1.Text
      密码 = rs.Fields(2)
      rs.Close
      Unload Me
      Form1.Show
    Else
     MsgBox "密码不正确", vbOKOnly + vbExclamation, ""
     Text2.SetFocus
   End If
  End If
 End If
    cnt = cnt + 1
      If cnt = 3 Then
         Unload Me
       End If
      Exit Sub
       
      
End Sub

Private Sub Label4_Click()
Frmzhuce.Show
Unload Me

End Sub

Private Sub Label5_Click()
Frmmmxiugai.Show
Unload Me

End Sub

⌨️ 快捷键说明

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