We have a legacy component that has been converted from VB6 to VB.Net.
The VB component was called from an ASPX page using Request("param") to pass optional parameters to function calls. That means the value is null/nothing if the parameter is not present.
The parameters were then added to an ADODB call of a store procedure using Parameters.Append
.
When used from VB6 missing, Request("param") values were coerced into empty strings when passed to the VB6 component. This meant that the ADODB call was satisfied (for required parameters).
When the code was ported to VB.Net, the null Request("param") values are now passed as null values (VB nothing?) and Parameters.Append
skips adding the value if it is nothing
. This caused the stored procedure calls to break as a required param was missing.
If we change the component's function parameters to be optional
and have paramname as string = ""
defaults, will a null/nothing value be converted to an empty string, or is null/nothing treated differently to a parameter being simply missing?
Apologies for the use of the term null, but 99% of my work is C# :)
If you pass Nothing
as the argument for an Optional String parameter that defaults to an empty string, the variable inside the method will have a value of Nothing
. It will not have the value of an empty string. They are two different values, because strings in .Net are reference types. You should add code to top of the method to replace Nothing
for those parameters with an empty string.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With