SEARCH
0-9 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
Prev | Current Page 97 | Next

Jim DeMarco

"Pro Excel 2007 VBA"

We??™re instantiating the Parameter object with this line of code:
Set prm = New ADODB.Parameter
Then we are setting various properties. You might have noticed when looking at the parameters
list in SQL Server that some parameters were numeric and others were various flavors of
char (nchar and nvarchar, to be exact). These parameters require an additional property setting,
the Parameter.Size property. You also have other properties available, such as the Direction
property, which you can set to determine whether a value is for input or output.
With prm
.Name = "EmployeeID"
.Type = adInteger
.Value = Cells(RowNum, 1).Value
End With
colReturn.Add prm
Once the properties are set, we add the prm variable to our colReturn collection.
We reuse the prm variable by reinstantiating it before setting the next set of properties and
adding to the collection. This is an effective way of reusing an object and ensures you don??™t
have any ???leftover??? property settings lingering.
This process is repeated for each input parameter that uspUpdateEmployeePersonalInfo
requires us to provide. Finally, we set the function??™s return value to the internal collection
object:
Set SetParams = colReturn
CHAPTER 2 n DATA IN, DATA OUT 85
Next, we??™ll finish setting up the Command object and loop through the collection of
Parameter objects, appending each to the Command object??™s Parameters collection:
With cmd
.CommandType = adCmdStoredProc
.CommandText = "HumanResources.


Pages:
85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109