K Feening
asked on
VB Sql
Hi
Hope this is enough information
VB.net
SQL Server 2008
Code -
parameters = new DataParameterCollection
paramerers.add("@test", cStr(Values(2)))
Produces an DBNull to string not valid error
How do I test cStr(Values(2) is Null set the Parameter to ""
or if not Null paramerers.add("@test", cStr(Values(2)))
Thanks
Hope this is enough information
VB.net
SQL Server 2008
Code -
parameters = new DataParameterCollection
paramerers.add("@test", cStr(Values(2)))
Produces an DBNull to string not valid error
How do I test cStr(Values(2) is Null set the Parameter to ""
or if not Null paramerers.add("@test", cStr(Values(2)))
Thanks
ASKER
Thanks
as I asked how do I as you commented
Check whether @test returns the value
as I asked how do I as you commented
Check whether @test returns the value
Change
paramerers.add("@test", cStr(Values(2)))
to
If Not String.IsNullOrEmpty(Value s(2)) AND Not ISDBNull(Values(2)) Then
paramerers.add("@test", cStr(Values(2)))
Else
paramerers.add("@test", "")
End If
paramerers.add("@test", cStr(Values(2)))
to
If Not String.IsNullOrEmpty(Value
paramerers.add("@test", cStr(Values(2)))
Else
paramerers.add("@test", "")
End If
ASKER
Thanks but it causes errors
On the If Not String.IsNullOrEmpty(Value s(2)) Error -
Option strict on disallows implicit conversion from object to string
and Name isdbNull is not declared
Had to Change Value(2) to cstr(Value(2)) in the first line to remove object to string error and remove the ISDBNull but didn't work
Thanks
On the If Not String.IsNullOrEmpty(Value
Option strict on disallows implicit conversion from object to string
and Name isdbNull is not declared
Had to Change Value(2) to cstr(Value(2)) in the first line to remove object to string error and remove the ISDBNull but didn't work
Thanks
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Your trying to convert the null value into string that's why it returns "DBNull to string not valid" error..