NOTE: This technique is hazardous in that if the stored procedure changes theorder or direction of parameters, this code has to be changed. There is amuch smaller alternative, which gets the same results. By just listingthe name of the stored procedure for CommandText and refreshing theParameters Collection, ADO automatically fills the Parameters Collection,one for each parameter required by the stored procedure. However, one potential drawback to thismethod is the overhead involved. It does require a round trip to the server toget the parameter information, and thus there is a greater performance hitthan if you build the parameters yourself. This would be a good way to determine the correct parameters properties for a procedure. Use the information returned to set up the parameters in code as demonstrated above. This isdemonstrated in the following code:
This generates exactly the same rowset, but lets ADO fill the parameterscollection automatically and correctly (although this code correctly determines that thesecond parameter is an input parameter).
NOTE: Parameters.refresh will fail in some situations or return information that is not entirely correct. Parameters.refresh is particularly vulnerable when used on ASP pages. Please query on "parameters.refresh" to find other articles that talk about some of the problems associated with Parameter.refresh.
For additional information%1, click the article number%2 below to view the article%2 in the Microsoft Knowledge Base:
225897 ACC2000: How to Use Parameters with ActiveX Data Objects (ADO) and Jet
رقم الموضوع: 174223 - آخر مراجعة: 07/01/2004 20:48:35 - المراجعة: 1.1
Microsoft ActiveX Data Objects 1.0, Microsoft ActiveX Data Objects 1.5, Microsoft ActiveX Data Objects 2.0, Microsoft ActiveX Data Objects 2.1 Service Pack 2, Microsoft ActiveX Data Objects 2.5, Microsoft ActiveX Data Objects 2.6, Microsoft ActiveX Data Objects 2.7