examples icon indicating copy to clipboard operation
examples copied to clipboard

vbnullstring as parameter causes error

Open Energeer opened this issue 3 years ago • 1 comments

First of all thanks very much for this Library! Not sure if this is by design or if my usage is wrong, however if I pass a vbnullstring or "" as a parameter an error occurs.

The line below in AdoParameterProvider results in the size property of the ADO parameter defaulting to 0 for empty strings. The size property is not allowed to be 0 for string types (at least not in what I am using it for) and causes an error.

If IsCharMapping(Result.Type) And Len(Value) > 0 Then Result.Size = Len(Value)

I have fixed the issue in my project by changing the line to:

If IsCharMapping(Result.Type) Then
     If Len(Value) > 0 Then Result.Size = Len(Value) Else Result.Size = 1
End If

Is there a better way?

Energeer avatar May 25 '22 20:05 Energeer

Setting a minimum size of 1 seems like a sensible default indeed!

retailcoder avatar May 25 '22 23:05 retailcoder