I
Irishmaninusa
http://www.15seconds.com/issue/010718.htm
I am current writing a data access layer for a project I am on, and one of
the things I want to be able to do is use stored procedures with optional
values. The stored procedure part is not an issue, what is the issue is how
I call the stored procedure using ado.net. Currently I get the list of
parameters for the sp and store them in an array.
The current way that I add them to the command object is as follow(s):
'Traverse through the array of parameters for the stored procedure
For iLoop = 0 To iArrPost - 1
..Parameters.Add(arrParamList(iLoop).sParamName, _
arrParamList(iLoop).enuDataType, _
arrParamList(iLoop).iSize).Value = arrParamList(iLoop).oValue
..Parameters(iLoop).Direction = arrParamList(iLoop).enuDirection
Next
The problem with this is if the stored proceudre is like this
param1
param2
param 3
param4
with param1 being required and the rest optional, then if pass in param1 and
param3, it is going to write out the contents of param3 to be sent to param2
and that is what I am trying to avoid. So the code I found about is from
ado, but I am not sure if this is possible to do in ado.net or if there is a
clearer and better way of doing it. So if any one has any insight into this
please let me know. Thanks
JD
I am current writing a data access layer for a project I am on, and one of
the things I want to be able to do is use stored procedures with optional
values. The stored procedure part is not an issue, what is the issue is how
I call the stored procedure using ado.net. Currently I get the list of
parameters for the sp and store them in an array.
The current way that I add them to the command object is as follow(s):
'Traverse through the array of parameters for the stored procedure
For iLoop = 0 To iArrPost - 1
..Parameters.Add(arrParamList(iLoop).sParamName, _
arrParamList(iLoop).enuDataType, _
arrParamList(iLoop).iSize).Value = arrParamList(iLoop).oValue
..Parameters(iLoop).Direction = arrParamList(iLoop).enuDirection
Next
The problem with this is if the stored proceudre is like this
param1
param2
param 3
param4
with param1 being required and the rest optional, then if pass in param1 and
param3, it is going to write out the contents of param3 to be sent to param2
and that is what I am trying to avoid. So the code I found about is from
ado, but I am not sure if this is possible to do in ado.net or if there is a
clearer and better way of doing it. So if any one has any insight into this
please let me know. Thanks
JD