Reset to Null a parameter in an SQLCommand

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Help

I have a command that executes a stored procedure. The same command is executed thousands of times. Prior to each execution of the command, the parameters need to be reinitialized to null and then repopulated with new values. I've tried the following command

cmSql.parameters(3).value = vbNul

All that does is produce an error saying that it can't convert an enum type to a date
Not reinitializing the parameters after each execution is not an option. Surely there must be a time effective way to do this

Thanks in advance for your help
 
use = DbNull.Value
Help!

I have a command that executes a stored procedure. The same command is
executed thousands of times. Prior to each execution of the command, the
parameters need to be reinitialized to null and then repopulated with new
values. I've tried the following command.
cmSql.parameters(3).value = vbNull

All that does is produce an error saying that it can't convert an enum type to a date.
Not reinitializing the parameters after each execution is not an option.
Surely there must be a time effective way to do this.
 
Command.Parameters.Clear()


Help!

I have a command that executes a stored procedure. The same command is
executed thousands of times. Prior to each execution of the command, the
parameters need to be reinitialized to null and then repopulated with new
values. I've tried the following command.
cmSql.parameters(3).value = vbNull

All that does is produce an error saying that it can't convert an enum type to a date.
Not reinitializing the parameters after each execution is not an option.
Surely there must be a time effective way to do this.
 
Also, they don't need reinitialized, you can just change their values
directly.
 
Ok, the just call .Clear like Greg mentioned and recreate them. Some times
you can get away with reusing them, sometimes not..
sburns said:
Hey there, William,

Thanks for your help. I'll try the vbNull.Value and let you know the results.

Unfortunately I do need to reset the parameters to null as not all
parameters are used for each row of data inputed. Consequently, if there
was an address2 for one row, but the second row did not have an address2,
address2 would retain the value from the first row. This would be
unacceptable.
 
As it turns out, clearing out the parameters and dynamicaly rebuilding them looks to be the best solution. I will see how it does for speed

Thanks for your help.
 
Back
Top