F
Frédéric Mayot
Hi,
I'm trying to make a little wrapper to execute sql commands with parameters.
Execute("SELECT * FROM Table WHERE Stuff=@p1", somevar)
Public Shared Function Execute(ByVal sSQL As String, _
ByVal ParamArray params() As Object) As
Object
[...]
Dim oCmd As New SqlCommand(sSQL, oSQLConn)
[...]
For Each obj As Object In params
Dim param As New SqlParameter
param.Value = obj
oCmd.Parameters.Add(param)
Next
[...]
End Function
I don't want to pass the name of the parameters to the Execute function.
It seems that I can't do that.
Any idea ?
Thanks.
Fred
I'm trying to make a little wrapper to execute sql commands with parameters.
Execute("SELECT * FROM Table WHERE Stuff=@p1", somevar)
Public Shared Function Execute(ByVal sSQL As String, _
ByVal ParamArray params() As Object) As
Object
[...]
Dim oCmd As New SqlCommand(sSQL, oSQLConn)
[...]
For Each obj As Object In params
Dim param As New SqlParameter
param.Value = obj
oCmd.Parameters.Add(param)
Next
[...]
End Function
I don't want to pass the name of the parameters to the Execute function.
It seems that I can't do that.
Any idea ?
Thanks.
Fred