You are on page 1of 31

:

.1 .
.2 DAO ADO
.
.

.



.


.
)
( .
(SQL) 1

.

SQL

.

Oracle Microsoft Access : .SQL Server

.
)
2 (


.

1-5 Data
1 - Structured Query Language
2- Recordset

115






Data


.
Data
.
Data
) (dynaset-type
.


.
Data

.

) -5
.(1

(1-5 Data Caption


.
:1-5 (Data
-1 DataProj
. frmMain

.
-2 Data
Data .
-3 Data .
-4
txtFirst txtLast . Data

116

2-5
.
-5 DataProj.vbp .

(2-5 Data

.

1-1-5 Data
Data

.
Data .
:
DatabaseName Name .
Name Data
.
DatabaseName
Data .

Data

117

Jet :
DatabaseName .RecordSource
DatabaseName Data
RecordSource
.
Data
.
:

Access .
Composer
.
Biblio.mdb Nwind.mdb
.
:2-5 Data
(
-1 Data frmMain DataProj.vbp
.
Properties
-2 DatabaseName
) .(3-5
-3 Database Name
Composer.mdb .



tbiComposers
- 4
RecordSource ) .(4-5

(3-5 DatabaseName
.

118

(4-5
DatabaseName
RecordSource
.

:
DataField
RecordSource
Data .
.
-5 txtFirst .
-6 DataSource
Properties Data1 ) .(5-5
-7 DataField FirstName
.

119

(5-5 DataSource Data


.

(6-5
RecordSource Data DataField
.
-8 DataSource txtLastName
Data1 .
-9 Properties LastName
dataField txtLastName

) .(7-5
-10 ) .(8-5

120

(7-5
DataField
.

(8-5
Data .
Data





RecordSource
. Data DataSource

.

DataField .


1-5 .

121

(1-5
.

Text Box
Label
Image

PictureBox
CheckBox
ListBox
ComboBox


. .
. .


.

.
.
.
.
.
.
.


.

.
Data

.

2-5
Data Form Wizard


.
Add-Ins . Data Form

ADO Data
. ADO Data Data
.

Data Form
Add-Ins .

1-2-5 Data Form Wizard


-1 Add-Ins Add-In Manager
.
-2 .Add-In Manager VB6 Data




Form Wizard

122

Loaded/Unloaded ) .(9-5
Ok .

(9-5 Load on Startup


Data Form Add-Ins
.
IDE


.
:3-5 (
VB Data Form
tblWorks Composer.mdb
.
-1 Add-Ins Data-Form Wizard
.
-2 Introduction Next
) .(10-5

123

(10-5 Introduction
Data Form Wizard .
-3 Database Type Access
Next .
-4 Database Browse
Access Database

.
Composer.mdb .
Next .
:
Access XP , 2003
.

-5 frmWorks Form
Layout Single Record .
Binding Type ADO Data Control
Next ) .(11-5

124

(11-5
Form Layout .
-6 tblworks Record Source

(12-5
Record Source .
Record Source Available
fields .
-7  Next ) -5

.(13
Column to sort by
.
-8

) .(14-5
Next .
-9
) .(15-5
.rwp .

125

(13-5
.

. 
 .

(14-5
.

126

(15-5
.
-10 Finish . Data
Form Created .


Dnt show this Dialofg in the Future
. Ok .
-11 Project Properties
DataProj Properties Project .
Startup Object
-12 frmWorks
) .(16-5
-13 ) .(17-5

127

(16-5
Startup
.

(17-5
) (refreash
.
Data .
Data RecordSource


. Data
.
Data
.

) ActiveX Data Objects (ADO
. Data
.
128

3-5
ADO
Data
.
Data
.
Data
.




.

)
(.
:
ADO .
ADO ODBC RDO DAO .
ADO
. ADO
Microsoft Index Server
.
ADO OLE DB OLE DB
.
DAO Access Jet
ADO
OLE DB .

:
DataList DataGrid .DataCombo Active Data
) Objects (ADO
. ADO Data
Data.
ADO Data.

129

4-5
Data

ADO

DataList DataGrid
DataCombo ADO
Data .
: 4-5 (ADO Data
.1 Project Component
.
Microsoft ADO Data Control 6.0 (OLE DB) .2
Ok ) .(18-5
ADO Data
) .(19-5

(18-5 ADO Data


.

:


.

)
(.

130

(19-5 ADO Data .

.3 ADO Data
. adcCustomers

.
.4

. Build Use Connection
String Property
Pages Build ) .(20-5

(20-5 Property Pages


.
.5 OLE DB

.
131

AccessMicrosoft Jet 3.51


OLE DB Provider
) .(21-5 Next
.

(21-5 ADO Data


OLE DB .
Jet Access .

.6 .


.
Nwind.mdb
Database Name
) .(22-5

132

(22-5
.
User ID
. Access User ID
Admin .

.
.7 Test Connection
.
) (23-5
Ok .

.

(23-5
ADO Data .

133

.8
.
Custom
Recordsaurce ) .(24-5
2-
Command Type


abCmdTable .
Table or Stored Procedure Name Customers
. Ok .

( 24-5 RecordSource
ADO Data .

5-5 DataGrid
DataGrid

. DataGrid
.

.
:
.1 Project Components
.
Microsoft DataGrid Control 6.0 .2
Ok . DataGrid
.

134

DataGrid .
DataGrid .
.
DataGrid
ADO
Data .
: 5-5 DataGrid ( ADO Data
.1 DataGrid .
Name dgrdCustomers
.
adcCustomers .2 DataSource
) ADO Data
(.
DataSource DataGrid DataGrid

. Run
Start .
Customers ) .(25-5

DataGrid (25-5
.


DataGrid

. DataGrid

135

. Excel

1-5-5


.
DataGrid
.
DataGrid .
DataGrid Contact Name Company Name
Phone Number Country .
: 6-5 ( DataGrid
.1 DataGrid
Retrieve Fields .

Yes .
Recordsurce )
(Customers DataGrid
) .(26-5

(26-5 DataGrid

.
.2 DataGrid Edit

.

.
136

(27-5 DataGrid Edit


.
CustomerID
Delete )

.(27-5
.3 Region City Address Contact title
PostalCode Fax .

.
ContactName
CompanyName
ContactName Cut
CompanyName Paste
DataGrid .
.
.4 DataGrid
.

Properties . Columns


Caption
) .(28-5

137

(28-5 Caption Columns


.

.5 6
.

2-5-5
False
ADO Data
Visible

DataGrid
. DataGrid
. Align 1-
vbAligntop DataGrid
.

:
)(Private Sub Form_Resize
dgrdCustomers.Height = Me.scaleHeight
End sub

138

DataGrid (29-5 .
Customer Viewer
Caption

3-5-5 DataGrid
DataGrid


. 2-5
.
:


.
.

(2-5 DataGrid

139

Align

DataGrid
.
True
DataGrid
.
True

.
True
Delete
DataGrid .
True

.
True
Validate
.

.

.

RowDivider Style


.
Tab
DataGrid .
Tab
.


AllowAddNew

AllowArrows

AllowDeleet

AllowUpdate

CausesValidation

ColumnHeaders
HeadLines

TabAcrossSplits

TabAction
WrapcellPointer

:



DataGrid .

.


.




grid .
.
DataGrid
140

.
DataGrid
.

6-5 DataList
DataList DataGrid .

.

.

. DataGrid DataList ADO
Data .
: 7-5 ( DataList
.1 ADO Data
Customers Nwind.mdb
.
.2 DataList Components
)
Microsoft DataList Control 6.0
(.
.3 DataList
.
.4 DataList dlstCustomers .
.5 RowSource adcCustomers
.

.
ListField CompanyName .

141

(30-5 DataList
.

.6 )
.(30-5

.
DataList
:
) (Private sub Form_Resize
dlstCustomers.Height = Me.scaleHeight
dlstCustomers.width = Me.scalewidth
End sub

1-6-5 DataList
DataList
DataGrid
DataGrid ) .(3-5
(3-5 DataList

CausesValidation True
Validate
.
DataList



IntegralHeight

MatchEntry DataList

.

142

7-5 DataCombo
DataList
DataCombo
.

.
. DataCombo
ComboBox )
( 100 .
: 8-5 ( DataCombo
.1 ADO Data
Customers
Nwind.mdb .
DataList DataCombo
DataCombo
.
.2 DataCombo .

dcboCustomers
.

(31-5 DataCombo CompanyName


Shippers .

DataCombo
Rowsource
.3
adcCustomers ListField CompanyName
) DataList (.


DataCombo
) .(31-5
143

DataCombo
DataList . Style
Style ComboBox .
DataCombo

. DataCombo

Style 2-
DropDown List .

8-5 Data Form Wizard




.
Data Form Wizard
.

(32-5
.


Data Form Wizard
) .(32-5

144


.
Binding Type
:
ADO Data Control
.
ADO Code ADO Data .

.
Class
.

.

145