.


:




:

































 

 

 

 





ShipOrders, , Boutique Fudge . . , , . UnitsInStock, .

UnitsInStock, . , Access?

, , , .

, . , , Access , . , ( DAO).

DAO , . .

* DAO . , . (, , ), , .

■ DAO . SQL- (. 6).


DAO . , CurrentDb. Execute, SQL-, :

CurrentDb.Execute MyUpdateCommand

, , .

Recordset. CurrentDb. OpenRecordset SQL- .

Dim Recordset

Set Recordset = CurrentDb.OpenRecordset(MySelectCommand)

Recordset , . Recordset.MoveNext. , , Recordset.EOF, (end-of-file). True, .

Recordset . Recordset.EOF , , Access Recordset. . MoveNext : Do While Recordset.EOF = False

' ProductName ■ MsgBox Recordset("ProductName")

' Recordset.MoveNext

Loop

, , , . ( .)

1 Sub UpdateStock()

' , DataAccessError

2 On Error GoTo DataAccessError

' SELECT

3 Dim Query

4 Query = _

"SELECT ProductID, Quantity FROM OrderDetails WHERE OrderID=" & ID


'

5 Dim Recordset

6 Set Recordset = CurrentDb.OpenRecordset(Query)

' .

'

7 Do Until Recordset.EOF

' ID

8 Dim ProductID, Quantity

9 ProductID = Recordset("ProductID"}

10 Quantity = Recordset("Quantity")

 

' UPDATE,

'

11 Dim UpdateCommand

12 UpdateCommand = _

"UPDATE Products SET UnitsInStock = UnitsInStock-" & _

13 Quantity & " WHERE ID=" & ProductID

'

14 CurrentDb.Execute UpdateCommand

' ( )

15 Recordset.MoveNext

16 Loop

'

17 Recordset.Close

18 CurrentDb.Close

19 Exit Sub

20 DataAccessError:

' .

'

21 MsgBox Err.Description

22 End Sub


.

1 . , , , Ship () .

2 Access , . , .

34 SQL-, OrderDetails, . ( SQL- SELECT . . " " 6.)

56 Recordset.

7 , Recordset.

810 ProductID Quantity
OrderDetails ( Recordset).

1113 SQL- UPDATE. . : UPDATE Products SET UnitsInStock = UnitslnStock-4 WHERE ID= 14. 4 14 .

14 .

1516 ( , Recordset ).

1718 .

19 . , - , !

2022 , - . .

, , . , . - , . !

 

 

.

D D

, Microsoft - , ADO (ActiveX Data Objects, ActiveX). DAO, ADO .


, Microsoft ADO , , SQL Server, a DAO Access.

Access (), ADO DAO Access. ( Microsoft, , , .) , DAO, Access. , DAO , . ADO VB-, , , DAO, , - , ADO DAO.


VI





:


: 2016-03-28; !; : 402 |


:

:

, ,
==> ...

1298 - | 1280 -


© 2015-2024 lektsii.org - -

: 0.018 .