How to capture a StoredProcedureParameterCollection for ServerA's Sp to update ServerB
VS2010 I am reading any existing params and I want to load them into a ByRef params As StoredProcedureParameterCollection for use later.
As the code runs I get a null exception error and I cannot understand why? p has values for use to param and param has values for params.
For Each p As StoredProcedureParameter In spF.Parameters
Dim param As StoredProcedureParameter = New StoredProcedureParameter(spF, p.Name, p.DataType)
params.Add(Add(param, cnt)) ' << Get a null exception her开发者_开发技巧e??
cnt = cnt + 1
Next
Anyone else done this? Please don't say buy red-gate. That door slammed on my fingers long ago. :(
To take the params from the From server and pass over to the To server you need to create a standalone paramsCollection
Dim paramsF as StoredProcedureParameterCollection
spF is the loaded up sp of the From db.
paramsF = spF.Parameters 'nothing to new up here just copy it outright!
As you build up the layers to the spT with the database, the script as well as the params:
For Each p As StoredProcedureParameter In paramsF
Dim pp As StoredProcedureParameter
pp = New StoredProcedureParameter(spT, p.Name, p.DataType)
spT.Parameters.Add(pp)
Next
精彩评论