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

📄 form1.frm

📁 一个数据库课程设计
💻 FRM
字号:
VERSION 5.00
Object = "{67397AA1-7FB1-11D0-B148-00A0C922E820}#6.0#0"; "MSADODC.OCX"
Object = "{CDE57A40-8B86-11D0-B3C6-00A0C90AEA82}#1.0#0"; "MSDATGRD.OCX"
Begin VB.Form Form1 
   Caption         =   "Form1"
   ClientHeight    =   8250
   ClientLeft      =   165
   ClientTop       =   735
   ClientWidth     =   9990
   LinkTopic       =   "Form1"
   ScaleHeight     =   8250
   ScaleWidth      =   9990
   StartUpPosition =   3  '窗口缺省
   Begin VB.TextBox Text1 
      Height          =   375
      Index           =   5
      Left            =   8640
      TabIndex        =   6
      Text            =   "Text1"
      Top             =   1320
      Width           =   1095
   End
   Begin VB.TextBox Text1 
      Height          =   375
      Index           =   4
      Left            =   7080
      TabIndex        =   5
      Text            =   "Text1"
      Top             =   1320
      Width           =   1095
   End
   Begin VB.TextBox Text1 
      Height          =   375
      Index           =   3
      Left            =   5280
      TabIndex        =   4
      Text            =   "Text1"
      Top             =   1320
      Width           =   1095
   End
   Begin VB.TextBox Text1 
      Height          =   375
      Index           =   2
      Left            =   3600
      TabIndex        =   3
      Text            =   "Text1"
      Top             =   1320
      Width           =   1095
   End
   Begin VB.TextBox Text1 
      Height          =   375
      Index           =   1
      Left            =   1920
      TabIndex        =   2
      Text            =   "Text1"
      Top             =   1320
      Width           =   1095
   End
   Begin VB.TextBox Text1 
      Height          =   375
      Index           =   0
      Left            =   360
      TabIndex        =   1
      Text            =   "Text1"
      Top             =   1320
      Width           =   1095
   End
   Begin MSAdodcLib.Adodc Adodc1 
      Height          =   735
      Left            =   2640
      Top             =   8160
      Visible         =   0   'False
      Width           =   5895
      _ExtentX        =   10398
      _ExtentY        =   1296
      ConnectMode     =   0
      CursorLocation  =   3
      IsolationLevel  =   -1
      ConnectionTimeout=   15
      CommandTimeout  =   30
      CursorType      =   3
      LockType        =   3
      CommandType     =   2
      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:\zhaozhibin\db1.mdb;Persist Security Info=False"
      OLEDBString     =   "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=F:\zhaozhibin\db1.mdb;Persist Security Info=False"
      OLEDBFile       =   ""
      DataSourceName  =   ""
      OtherAttributes =   ""
      UserName        =   ""
      Password        =   ""
      RecordSource    =   "data"
      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 MSDataGridLib.DataGrid DataGrid1 
      Bindings        =   "Form1.frx":0000
      Height          =   6375
      Left            =   240
      TabIndex        =   0
      Top             =   2160
      Width           =   9615
      _ExtentX        =   16960
      _ExtentY        =   11245
      _Version        =   393216
      AllowUpdate     =   0   'False
      Enabled         =   -1  'True
      HeadLines       =   1
      RowHeight       =   18
      BeginProperty HeadFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "MS Sans Serif"
         Size            =   12
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "楷体_GB2312"
         Size            =   12
         Charset         =   134
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Caption         =   "                              "
      ColumnCount     =   2
      BeginProperty Column00 
         DataField       =   ""
         Caption         =   ""
         BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
            Type            =   0
            Format          =   ""
            HaveTrueFalseNull=   0
            FirstDayOfWeek  =   0
            FirstWeekOfYear =   0
            LCID            =   2052
            SubFormatType   =   0
         EndProperty
      EndProperty
      BeginProperty Column01 
         DataField       =   ""
         Caption         =   ""
         BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
            Type            =   0
            Format          =   ""
            HaveTrueFalseNull=   0
            FirstDayOfWeek  =   0
            FirstWeekOfYear =   0
            LCID            =   2052
            SubFormatType   =   0
         EndProperty
      EndProperty
      SplitCount      =   1
      BeginProperty Split0 
         BeginProperty Column00 
         EndProperty
         BeginProperty Column01 
         EndProperty
      EndProperty
   End
   Begin VB.Label Label1 
      Caption         =   "类别"
      Height          =   375
      Index           =   5
      Left            =   8640
      TabIndex        =   12
      Top             =   480
      Width           =   975
   End
   Begin VB.Label Label1 
      Caption         =   "电话"
      Height          =   375
      Index           =   4
      Left            =   7080
      TabIndex        =   11
      Top             =   480
      Width           =   975
   End
   Begin VB.Label Label1 
      Caption         =   "名字"
      Height          =   375
      Index           =   3
      Left            =   5400
      TabIndex        =   10
      Top             =   480
      Width           =   975
   End
   Begin VB.Label Label1 
      Caption         =   "地址"
      Height          =   375
      Index           =   2
      Left            =   3720
      TabIndex        =   9
      Top             =   480
      Width           =   975
   End
   Begin VB.Label Label1 
      Caption         =   "部门"
      Height          =   375
      Index           =   1
      Left            =   1920
      TabIndex        =   8
      Top             =   480
      Width           =   975
   End
   Begin VB.Label Label1 
      Caption         =   "编号"
      Height          =   375
      Index           =   0
      Left            =   360
      TabIndex        =   7
      Top             =   480
      Width           =   975
   End
   Begin VB.Menu chang 
      Caption         =   "修改(&C)"
   End
   Begin VB.Menu delete 
      Caption         =   "删除(&D)"
   End
   Begin VB.Menu regist 
      Caption         =   "登记(&R)"
   End
   Begin VB.Menu search 
      Caption         =   "查询(&S)"
   End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit

Private Sub chang_Click()

  Dim DBConn As ADODB.Connection
  Dim DBRst As ADODB.Recordset
  Dim SqlText As String
  
  Set DBConn = CreateObject("ADODB.Connection")
  Set DBRst = CreateObject("ADODB.Recordset")
  
  DBConn.ConnectionString = "DBQ=" + App.Path + "\db1;Driver={Microsoft Access Driver (*.mdb)}"
  DBConn.Open
  
  Set DBRst.ActiveConnection = DBConn
  SqlText = "Select * from data where num= " + Text1(0).Text
  
  DBRst.Open SqlText, , 2, 3    'Open recordset.
   SqlText = " update  data set dep='" + Text1(1).Text + "', add= '" + Text1(2).Text + "',  name= '" + Text1(3).Text + "', mobile ='" + Text1(4).Text + "', style='" + Text1(5).Text + "'where num = " + Text1(0).Text
  DBConn.Execute (SqlText)

   

  MsgBox "操作成功!!!"
   Adodc1.Refresh
  DBRst.Close
  DBConn.Close
  
  


End Sub

Private Sub delete_Click()

Dim DBConn As ADODB.Connection
  Dim DBRst As ADODB.Recordset
  Dim SqlText As String
  
  Set DBConn = CreateObject("ADODB.Connection")
  Set DBRst = CreateObject("ADODB.Recordset")
  
  DBConn.ConnectionString = "DBQ=" + App.Path + "\db1;Driver={Microsoft Access Driver (*.mdb)}"
  DBConn.Open
  
  Set DBRst.ActiveConnection = DBConn
  SqlText = "Select * from data  "
  
  DBRst.Open SqlText, , 2, 3    'Open recordset.
  
  SqlText = " delete * from data where num = " + Str(DataGrid1.Row + 1)
  
  
  
  
  
  
  
  
  
  DBConn.Execute (SqlText)
  
  MsgBox "操作成功!!!"
    Adodc1.Refresh
  
 DBRst.Close
  DBConn.Close
  
   

End Sub

Private Sub DataGrid1_RowColChange(LastRow As Variant, ByVal LastCol As Integer)
   ' 显示用户所单击的单元的文字、行和列的信息。


   





  Dim DBConn As ADODB.Connection
  Dim DBRst As ADODB.Recordset
  Dim SqlText As String
  
  Set DBConn = CreateObject("ADODB.Connection")
  Set DBRst = CreateObject("ADODB.Recordset")
  
  DBConn.ConnectionString = "DBQ=" + App.Path + "\db1;Driver={Microsoft Access Driver (*.mdb)}"
  DBConn.Open
  
  Set DBRst.ActiveConnection = DBConn
  SqlText = " select num from data where num is not null"
 ' SqlText = " select * from data where num =" + Str(DataGrid1.Row + 1)
  Set DBRst = DBConn.Execute(SqlText)
  'Open recordset.
  Dim a(100), i As Integer
  
For i = 1 To 20
 a(i) = DBRst(0)
 DBRst.MoveNext
    If i = 20 Then
   
    End If
    
   

 Next i

  
    
 
 DBRst.Close
 DBConn.Close
 
 


Dim DBConn1 As ADODB.Connection
  Dim DBRst1 As ADODB.Recordset
  Dim SqlText1 As String
  
  Set DBConn1 = CreateObject("ADODB.Connection")
  Set DBRst1 = CreateObject("ADODB.Recordset")
  
  DBConn1.ConnectionString = "DBQ=" + App.Path + "\db1;Driver={Microsoft Access Driver (*.mdb)}"
  DBConn1.Open
  
  Set DBRst1.ActiveConnection = DBConn1
 SqlText1 = " select * from data where num =" + Str(a(DataGrid1.Row + 1))
 Set DBRst1 = DBConn1.Execute(SqlText1)
  Text1(0).Text = DBRst1(0)
 Text1(1).Text = DBRst1(1)
 Text1(2).Text = DBRst1(2)
Text1(3).Text = DBRst1(3)
 Text1(4).Text = DBRst1(4)
 Text1(5).Text = DBRst1(5)
 
 
 
 'Text1(1).Text
'  DBRst("Stu_Age") = Text1(2).Text
 
 ' DBRst("Stu_Rem") = Text1(3).Text
 ' DBRst.Update
  

  
  DBRst1.Close
  DBConn1.Close
     
End Sub

Private Sub regist_Click()


  Dim DBConn As ADODB.Connection
  Dim DBRst As ADODB.Recordset
  Dim SqlText As String
  
  Set DBConn = CreateObject("ADODB.Connection")
  Set DBRst = CreateObject("ADODB.Recordset")
  
  DBConn.ConnectionString = "DBQ=" + App.Path + "\db1;Driver={Microsoft Access Driver (*.mdb)}"
  DBConn.Open
  
  Set DBRst.ActiveConnection = DBConn
  SqlText = "Select * from data  "
  DBRst.Open SqlText, , 2, 3    'Open recordset.
  
  DBRst.AddNew
   
  DBRst("dep") = Text1(1).Text
  DBRst("add") = Text1(2).Text
  DBRst("name") = Text1(3).Text
  DBRst("mobile") = Text1(4).Text
  DBRst("style") = Text1(5).Text
  DBRst.Update
  
  MsgBox "操作成功!!!"
  
  DBRst.Close
  DBConn.Close
  


GoTo aaa

End Sub

Private Sub search_Click()
Form5.Show
End Sub



aaa

Form1.Refresh

⌨️ 快捷键说明

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