???? Access ????????? ??? parameterized ?????? ????? ?? ????? ???? ????

???? ?????? ???? ??????
???? ID: 281870 - ?? ???????? ?? ?????? ??? ?? ?? ???? ???? ???? ??.
Moderate: ??? ??????, ??????, ?? ?????????????? ??????? ?????? ???

?? ???? Microsoft Access ????????? (.adp) ?? ??? ???? ???? ???? ???

??? ?? ??????? ???? | ??? ?? ??????? ????

?? ????? ??

??????

?????? ????? ???? ?? ??? ???? ???? ?????????? ?? ????? ??? ?? ?? ?? ????? ????? ?????? ????? ???? ??? ??? ?????? ????? ?? ??? ?????? ????? ?? ?????? ?? ?????? ?? ????????? ?? ??? ????? ?? ?????? ???? ?? ???????? ??, ?? ?? ?????? ????? ???? ?? ??? ??? ???? ??? ???? ???? ????

?? ???? ??? ?????? NorthwindCS.adp ????? ????????? ??? ?????? ??????? ?? ??? ??? ?????? ????? ?????? ??? ?????? ????? ??????? ?????? ?????? ??? ???? ??? ?? ???? ?? ???? ???? ???? ??? ?? ????? ??, ?? ???? ??????? ????? ??, ????? ???? ?? ????? ???? ??? ???

?? ??? ?????? ?????? ??? ???? ?? ??? ???? ?? ??? ???? ????? ?? ??? ??? ???? ??????? ?? ????? ?? ???? ??? ?? ??????? ????? ???? Access ????????? (.adp) Microsoft SQL Server 2000 ?? ???? ????? ?? ??? ???? ?? ??????? ?? ???? ??? ??? ????? ???? ??? ????

???? ???????

?????? ????? ??? ??? ??

?? ?????? ??? ???? ???? ???? ?? ??????? ?????? ?? ???? ????????? ???? ?? ?? ?????? ??????? ?? ???? ?????? ????? ????? ?? ??? ???? ?????? ???
  1. ?????? ?? ??? ??? ??????? ????? ??? ??????
  2. ????? ????? ???, ????? ???????????? ???????, ?? ?? ??????? ?? ???? ?????? ????? ???????
  3. ???????? ?? ????? ?????, ?? ??? ??? ??? ??? ?????? ?? ?????? ?? ?????, ?? ?? ????? ????next.
  4. ??????? ?? ????? ?????, ?? ???? ?????? ?? ????? ????, ?? ???? ??? ????? ????next.
  5. ??????? ?? ????? ?????, ?? OrderID, CustomerID ?? OrderDate ?? ??? ??? ?????? ????? ??? ?????? ?????, ?? ???? ???next.
  6. ???????? ?? ???? ?????, ?? ????? ???? ???? ?? ???????? ????? ??????, ?? ???? ??? ?? ?????? ???? ?? ????? CustomerID ????? ????? ????? ????,next.
  7. ???????? ?? ??????? ?????, ?? ????? ????nextOrderID ???????? ???? ?? ???? ??????? ??? ?? ????? ???? ?? ??? ????? ?? ??? ??? ??????? ???? ???? ?? ??? ???:?
  8. ???????, ??? ??? ????? ?? ??? ??? ??? ????, ?? ???? ??? ?? ??? ???? ?? ??? ????? ??next.
  9. ???????? ?? ????? ?????, ?? ?????? ????? ???????? ?? ??? ?????? ????-????? ????, ?? ???? ?????????.
  10. ?????? ????? ?? ??? ??? ????? ?? ?????, ?? ?? ???? ?? ??? ?????? ????? ?? ??? ?????SelectOrderCombo.
  11. ??? ????OnClick?????? ????? ??? ????? ????? ????????? ???? ?? ??? ???:
    Private Sub SelectOrderCombo_Click()
    On Error GoTo Err_SelectOrderCombo_Click
        Dim stDocName As String
        Dim stLinkCriteria As String
    
        stDocName = "Orders"
    
        stLinkCriteria = "[OrderID]=" & Me![SelectOrderCombo]
        DoCmd.OpenForm stDocName, , , stLinkCriteria
    
    Exit_SelectOrderCombo_Click:
        Exit Sub
    
    Err_SelectOrderCombo_Click:
        MsgBox Err.Description
        Resume Exit_SelectOrderCombo_Click
    
    End Sub
    					

?????? ????? ?? ????? ???? ?? ??? ??? ?? ??????

?? ?????? ??? ?? ??????? ?????? ????? ?? ????? ???? ?? ??? ????? ?? ???? ??? ?? ?????? ??? ????? ??? ??????? ??? ?? ???? ?? ?? ??? ????, ?? ???? ??? ?????? ????? ?? OnEnter ????? ?? ??? ??????? ??? ???????

????? ???? ????????? 1 ?? 2, ?????? ????? ????? ??, ?? ?? ??? OnClick ???? ?? ?????? ????? ?? ???? ?? ???? ??????? ?????? ?? ??? ???? ???? ????????? ???? ?? ??? ?????? ??????

???:: ??????? CustomerID ????? ??? ??? ??? ??????? ??, ??? ?????? ????? (') ??????? ?????? ?? ??-??? concatenated ???? ?????? ?????? ?? ??? ????? ???? ??? ???? ??? ?? ?????? ??:
WHERE CustomerID = '" & Forms![Customers]![CustomerID] & "'"
				
?? ???:
WHERE CustomerID = 'ALFKI'
				

???? 1: ?? Hoc ??? ?? ????? ????

??? ????OnEnter?????? ????? ??? ????? ????? ????????? ???? ?? ??? ???:
Me.SelectOrderCombo.RowSource = "SELECT TOP 100 PERCENT OrderID, CustomerID, OrderDate FROM Orders WHERE " _
     & "CustomerID = '" & Forms![Customers]![CustomerID] & "' ORDER BY OrderDate DESC"

				

???? 2: ???? SQL Server ????? ?? ????? ????

  1. ????? ??????? ??? ??? ??? ????? ?????, ?? ?? OrderID, CustomerID ?? OrderDate ????? ?? ?? ??? ???? ???? ??????? ?? ?????? ?? ?????? ???? ?? ???? ?? ????? ???? ?? ??? ??? ????????? ?????????? ?? ??? OrderDate ????? ?? ?????????.
  2. ????? ?? vwCustomerOrders ?? ??? ??? ???????
  3. ??? ????OnEnter?????? ????? ??? ????? ????? ????????? ???? ?? ??? ???:
    Me.SelectOrderCombo.RowSource = "SELECT * FROM vwCustomerOrders WHERE CustomerId = '" & Forms![Customers]![CustomerID] & "'"
    					
????????? 3 ?? 4, ?????? ????? ?? ???Requery???????? ????????? ?? ??? ???? ?????? ??? ???? ?? ??? SQL ?????? re-execute ???? ?? ??? OnEnter ????? ?? ?????? ?? ??? ???? ???? ??? ?? ???????? ??? ???????? ??????? ??? ?????? @ ControlName ?? ????? ???? ?? ??? ???????? ?? ??? ??? ???????? ??? ????? ???????? ??? ?? ?????? ????????? ???? ?? ?? ??? ???? ?????? ?? ?????? ?????

????? ?????? ??? ?????? ????? ??????? ?????? ?? ??? ??? ???? ?? ???? ???? ?? ??? CustomerID ??? ????? ??? ??????? ?????? ID ???, ??????? ?? ??? ???????? ????????? ?? SQL ?????? ?????? CustomerID ??? ????? ??? ???? ?????? ?? ???? ????

???? 3: ???????? ????????? ???? SQL ????? ?? ????? ????

  1. ???????? designer ??? ?? ??? ????????? ?? ??????
  2. ???? ?????? ?? ??? ????, ?? ?? ?????? OrderID, CustomerID ?? OrderDate ????? ???????? ????????? ?? ????
  3. ENTER@ CustomerIDCustomerID ????? ?? OrderDate ????? ???? ?? ??? ?????? ?? ??? ??? ???? ??????
  4. ???????? ????????? ?? spCustomerOrders ?? ??? ??? ??????, ?? ???? ??? ??? ?????
  5. SpCustomerOrders ???????? ????????? ?????? ????? ?? ??? ?????? ????? ?? ??? ??? ??? ?????

    ???:: ????? SQL ??? ????? ?? ?? Stored ?????? ????? ?? ????????? ???????:
    CREATE PROCEDURE dbo.spCustomerOrders
      (@CustomerID varchar(5))
      AS SELECT OrderID, CustomerID, OrderDate
      FROM   dbo.Orders
      WHERE  (CustomerID = @CustomerID)
      ORDER BY OrderDate DESC
    					
  6. ??? ????OnEnter?????? ????? ??? ????? ????? ????????? ???? ?? ??? ???:
    Me.SelectOrderCombo.Requery
    					

???? 4: ???? SQL Server 2000 ?????? ?? ????? ????

?? ?? ???? ?? ????? ???? ?? ???? ???, ??? Access ????????? ?? ????? SQL Server 2000 ?? ??? ?? ??????? ???? ????? ?? ??? ????
  1. ???????? designer ??? ??? ?????? ??? ???
  2. ???? ?????? ?? ??? ????, ?? ?? ?????? OrderID, CustomerID ?? OrderDate ????? ???????? ????????? ?? ????
  3. ENTER@ CustomerIDCustomerID ????? ?? OrderDate ????? ???? ?? ??? ?????? ?? ??? ??? ???? ??????
  4. ?????? ?? fnCustomerOrders ?? ??? ??? ??????, ?? ???? ??? ??? ?????
  5. FnCustomerOrders ?????? ?????? ????? ?? ??? ?????? ????? ?? ??? ??? ??? ?????

    ???:: ????? SQL ??? ????? ?? ?? Stored ?????? ????? ?? ????????? ???????:
    CREATE FUNCTION dbo.fnCustomerOrders
      (@CustomerID varchar(5))
      RETURNS TABLE
      RETURN ( SELECT TOP 100 PERCENT OrderID, CustomerID, OrderDate
      FROM   dbo.Orders
      WHERE  (CustomerID = @CustomerID)
      ORDER BY OrderDate DESC )
    					
  6. ??? ????OnEnter?????? ????? ??? ????? ????? ????????? ???? ?? ??? ???:
    Me.SelectOrderCombo.Requery
    					
?? ??????? ?? ??????? ????, ??????? ?????, ?? ??? ?? ???? ????? ?????? ????? ?? ??? ????? OnEnter ????? requeries ?????? ????? ???, ??????? ?????? ?? ??? ' ???? ' ?? ?? ???? ????: ????? ?? ??? ??? ?? ??? ???? ????? ??, ?????? ????? ?? OnClick ????? ?????????, ?? ???? ??????? ?? ????, ????? ???? ????????? ?????

???

???? ID: 281870 - ????? ???????: 02 ?????? 2010 - ??????: 3.0
???? ???? ???? ??:
  • Microsoft Access 2002 Standard Edition
??????: 
kbprogramming kbadp kbclientserver kbhowto kbmt KB281870 KbMthi
???? ?????? ????????
??????????: ?? ???? ?? ???? ??????? ?? ????? ?? Microsoft ????-?????? ?????????? ?????? ?????? ???? ??? ??. Microsoft ???? ??? ????-???????? ?? ????-???????? ????? ?????? ?? ???? ???????? ???? ?? ???? ????? ????? ??? ?? ??? ?????? ?? ???? ???? ???? ??? ????? ??. ???????, ????-???????? ???? ????? ???? ???? ???? ???. ?????, ????????, ?????-???? ?? ??????? ?? ???????? ?? ???? ???, ???? ?? ??? ?????? ???? ???? ??? ????? ??? ?? ???? ??. Microsoft ??????? ??? ???? ?? ?????? ?? ??????????, ????????? ?? ??? ?????? ?? ???? ????? ?? ???? ???????? ?? ??? ???? ????? ?? ??? ????????? ???? ??. Microsoft ????-?????? ?????????? ?? ????? ?????? ?? ?? ??? ??.
?????????? ?? ??????? ????????? ??????? ??:281870

??????????? ???

 

Contact us for more help

Contact us for more help
Connect with Answer Desk for expert help.
Get more support from smallbusiness.support.microsoft.com