www.pudn.com > Mydb2.zip > FrmDB2.frm
VERSION 5.00
Object = "{67397AA1-7FB1-11D0-B148-00A0C922E820}#6.0#0"; "msadodc.ocx"
Begin VB.Form Form1
Caption = "Form1"
ClientHeight = 3660
ClientLeft = 60
ClientTop = 345
ClientWidth = 7425
LinkTopic = "Form1"
ScaleHeight = 3660
ScaleWidth = 7425
StartUpPosition = 3 '窗口缺省
Begin VB.CommandButton Command1
Caption = "Add >>"
Height = 375
Left = 4080
TabIndex = 12
Top = 240
Width = 975
End
Begin VB.CommandButton CmdLast
Caption = "Last"
Height = 375
Left = 4440
TabIndex = 11
Top = 3120
Width = 1095
End
Begin VB.CommandButton CmdFirst
Caption = "First"
Height = 375
Left = 3000
TabIndex = 10
Top = 3120
Width = 1095
End
Begin VB.CommandButton CmdPrivous
Caption = "Privous"
Height = 375
Left = 1680
TabIndex = 9
Top = 3120
Width = 1095
End
Begin VB.CommandButton CmdNext
Caption = "Next"
Height = 375
Left = 240
TabIndex = 8
Top = 3120
Width = 1215
End
Begin MSAdodcLib.Adodc Ado
Height = 375
Left = 5160
Top = 960
Visible = 0 'False
Width = 1335
_ExtentX = 2355
_ExtentY = 661
ConnectMode = 0
CursorLocation = 3
IsolationLevel = -1
ConnectionTimeout= 15
CommandTimeout = 30
CursorType = 3
LockType = 3
CommandType = 8
CursorOptions = 0
CacheSize = 50
MaxRecords = 0
BOFAction = 0
EOFAction = 0
ConnectStringType= 1
Appearance = 1
BackColor = -2147483643
ForeColor = -2147483640
Orientation = 0
Enabled = -1
Connect = ""
OLEDBString = ""
OLEDBFile = ""
DataSourceName = ""
OtherAttributes = ""
UserName = ""
Password = ""
RecordSource = ""
Caption = ""
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "宋体"
Size = 9
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
_Version = 393216
End
Begin VB.TextBox Text4
Height = 495
Left = 1680
TabIndex = 7
Top = 2040
Width = 2175
End
Begin VB.TextBox Text3
Height = 375
Left = 1680
TabIndex = 6
Top = 1440
Width = 2175
End
Begin VB.TextBox Text2
Height = 375
Left = 1680
TabIndex = 5
Top = 840
Width = 2175
End
Begin VB.TextBox Text1
DataSource = "Ado"
Height = 375
Left = 1680
TabIndex = 4
Top = 240
Width = 2175
End
Begin VB.Label Label4
Caption = "Company"
Height = 375
Left = 240
TabIndex = 3
Top = 2160
Width = 975
End
Begin VB.Label Label3
Caption = "Phone"
Height = 375
Left = 240
TabIndex = 2
Top = 1440
Width = 975
End
Begin VB.Label Label2
Caption = "Last Name"
Height = 375
Left = 240
TabIndex = 1
Top = 840
Width = 1095
End
Begin VB.Label Label1
Caption = "First Name"
Height = 375
Left = 240
TabIndex = 0
Top = 240
Width = 1215
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim CON1 As ADODB.Connection '声明连接
Dim cmdCommand As ADODB.Command '声明命令
Dim rstRecord As ADODB.Recordset '声明记录
Dim strFiel As String '字段
Dim strDBProvider As String '声明数据库路径信息
Private Sub CmdFirst_Click()
'Move to first record
rstRecord.MoveFirst
Text1.Text = rstRecord.Fields("FirstName")
End Sub
Private Sub CmdLast_Click()
'Move to last record
rstRecord.MoveLast
Text1.Text = rstRecord.Fields("FirstName")
End Sub
Private Sub CmdNext_Click()
'Move to next record
If rstRecord.EOF = False Then
rstRecord.MoveNext
If rstRecord.EOF Then
rstRecord.MoveFirst
End If
Else
rstRecord.MoveFirst
End If
Text1.Text = rstRecord.Fields("FirstName")
End Sub
Private Sub CmdPrivous_Click()
'Move to privous record
If rstRecord.BOF = False Then
rstRecord.MovePrevious
If rstRecord.BOF Then
rstRecord.MoveLast
End If
Else
rstRecord.MoveLast
End If
Text1.Text = rstRecord.Fields("FirstName")
End Sub
Private Sub Command1_Click()
rstRecord.Fields("FirstName") = Text1.Text
rstRecord.Update
Text1.Text = rstRecord.Fields("FirstName")
End Sub
Private Sub Form_Load()
'连接
strDBProvider = "Provider=Microsoft.Jet.OLEDB.3.51;" & _
"Persist Security Info=False;data source =" & App.Path & _
"\MyDB.mdb;mode = ReadWrite"
strFiel = ""
Set CON1 = New ADODB.Connection
CON1.Open strDBProvider
Set rstRecord = New ADODB.Recordset
rstRecord.CursorType = adOpenStatic
rstRecord.LockType = adLockOptimistic
rstRecord.Open "Table1", CON1, , , adCmdTable
Text1.Text = rstRecord.Fields("FirstName")
'Ado.ConnectionString = "Provider=Microsoft.Jet.OLEDB.3.51;" & _
'"Persist Security Info=False;data source =" & App.Path & _
'"\MyDB.mdb;mode = ReadWrite"
'Ado.CommandType = adCmdTable
'Ado.RecordSource = "Table1"
'Ado.Refresh
End Sub