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

📄 使用ado对象编程.frm

📁 一个商场财务系统
💻 FRM
字号:
VERSION 5.00
Begin VB.Form 使用ADO对象编程 
   BackColor       =   &H8000000A&
   Caption         =   "直接ODBC"
   ClientHeight    =   1995
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   6165
   LinkTopic       =   "Form1"
   ScaleHeight     =   1995
   ScaleWidth      =   6165
   StartUpPosition =   3  '窗口缺省
   Begin VB.CommandButton Command5 
      Caption         =   "退  出"
      Height          =   315
      Left            =   4755
      TabIndex        =   14
      Top             =   1530
      Width           =   1170
   End
   Begin VB.CommandButton Command4 
      Caption         =   "末记录"
      Height          =   315
      Left            =   3564
      TabIndex        =   13
      Top             =   1530
      Width           =   1170
   End
   Begin VB.CommandButton Command3 
      Caption         =   "下一记录 >"
      Height          =   315
      Left            =   2391
      TabIndex        =   12
      Top             =   1530
      Width           =   1170
   End
   Begin VB.CommandButton Command2 
      Caption         =   "< 前一记录"
      Height          =   315
      Left            =   1218
      TabIndex        =   11
      Top             =   1530
      Width           =   1170
   End
   Begin VB.CommandButton Command1 
      Caption         =   "首记录"
      Height          =   315
      Left            =   45
      TabIndex        =   10
      Top             =   1530
      Width           =   1170
   End
   Begin VB.TextBox Text5 
      Alignment       =   1  'Right Justify
      DataField       =   "基本工资"
      DataSource      =   "Data1"
      Height          =   270
      Left            =   4995
      TabIndex        =   9
      Text            =   "Text5"
      Top             =   810
      Width           =   855
   End
   Begin VB.TextBox Text4 
      Alignment       =   1  'Right Justify
      DataField       =   "最后学历"
      DataSource      =   "Data1"
      Height          =   270
      Left            =   2715
      TabIndex        =   7
      Text            =   "Text4"
      Top             =   840
      Width           =   1080
   End
   Begin VB.TextBox Text3 
      Alignment       =   2  'Center
      DataField       =   "性别"
      DataSource      =   "Data1"
      Height          =   270
      Left            =   960
      TabIndex        =   6
      Text            =   "Text5"
      Top             =   810
      Width           =   375
   End
   Begin VB.TextBox Text2 
      Alignment       =   1  'Right Justify
      DataField       =   "出生日期"
      DataSource      =   "Data1"
      Height          =   270
      Left            =   2880
      TabIndex        =   3
      Text            =   "Text2"
      Top             =   195
      Width           =   1830
   End
   Begin VB.TextBox Text1 
      Alignment       =   2  'Center
      DataField       =   "姓名"
      DataSource      =   "Data1"
      Height          =   285
      Left            =   945
      TabIndex        =   0
      Text            =   "Text1"
      Top             =   195
      Width           =   810
   End
   Begin VB.Label Label8 
      Caption         =   "性别:"
      Height          =   240
      Left            =   240
      TabIndex        =   8
      Top             =   840
      Width           =   570
   End
   Begin VB.Label Label7 
      AutoSize        =   -1  'True
      Caption         =   "基本工资:"
      Height          =   180
      Left            =   4005
      TabIndex        =   5
      Top             =   840
      Width           =   900
   End
   Begin VB.Label Label6 
      Caption         =   "最后学历:"
      Height          =   285
      Left            =   1785
      TabIndex        =   4
      Top             =   840
      Width           =   960
   End
   Begin VB.Label Label2 
      AutoSize        =   -1  'True
      Caption         =   "出生日期:"
      Height          =   180
      Left            =   1980
      TabIndex        =   2
      Top             =   240
      Width           =   900
   End
   Begin VB.Label Label1 
      Caption         =   "姓名:"
      Height          =   255
      Left            =   240
      TabIndex        =   1
      Top             =   240
      Width           =   600
   End
End
Attribute VB_Name = "使用ADO对象编程"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim Rs As New ADODB.Recordset
Private cn As Connection
Private Sub Form_Load()
'Dim cn As ADODB.Connection
Dim ConnStr As String
Dim Cmd As New ADODB.Command
Set cn = New ADODB.Connection
ConnStr = "DSN=职工情况SQL"
cn.ConnectionString = ConnStr
cn.Open
With Cmd
 .ActiveConnection = cn
 .CommandType = adCmdTable
 .CommandText = "表1"
End With
With Rs
 .CursorLocation = adUseClient
 .CursorType = adOpenStatic
 .LockType = adLockPessimistic
 .Open Cmd
End With
Set Text1.DataSource = Rs
Set Text2.DataSource = Rs
Set Text3.DataSource = Rs
Set Text4.DataSource = Rs
Set Text5.DataSource = Rs
Text1.DataField = "姓名"
Text2.DataField = "出生日期"
Text3.DataField = "性别"
Text4.DataField = "最后学历"
Text5.DataField = "基本工资"
End Sub
Private Sub Command1_Click()
Rs.MoveFirst
Rs.Update
End Sub
Private Sub Command2_Click()
If Rs.BOF Then
 Rs.MoveFirst
 Rs.Update
 Else
Rs.MovePrevious
End If
End Sub
Private Sub Command3_Click()
If Rs.EOF Then
 Rs.MoveLast
 Rs.Update
 Else
 Rs.MoveNext
End If
End Sub
Private Sub Command4_Click()
Rs.MoveLast
Rs.Update
End Sub
Private Sub Command5_Click()
cn.Close
Set cn = NOTIHG
'If Rs.BOF = True Or Rs.EOF = True Then
Unload Me
' Else
'Rs.Update
'Unload Me
'End If
End Sub




⌨️ 快捷键说明

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