2

I am calling the OTA API from HP Quality Centre and one of the calls requires sending a NULL.

This is the actual line of code:

stepF.AddItem(NULL)

This works perfectly in VBA and VB6 but VB.NET doesn't accept Nulls. Anyone know how to fix such an issue?

competent_tech
  • 44,465
  • 11
  • 90
  • 113

4 Answers4

5

You need to use Nothing, which is mostly equivalent to null.

SLaks
  • 868,454
  • 176
  • 1,908
  • 1,964
  • Unfortunately I'd already tried that and it results in an error stating that "Value does not fall within the expected range". – user1084071 Dec 07 '11 at 09:07
2

Nothing is the Null value for most reference types in VB.Net, I would recommend taking a look at Nullable(Of T) on either MSDN or some good information about it in this SO post, if the API you are using is a .Net web service you may be able to partial class the WSDL and fix although it sounds as though you are not.

Community
  • 1
  • 1
Gent
  • 2,675
  • 1
  • 24
  • 34
2

The correct value to use is System.DBNull.Value.

Even if the documentation tells us that this is generally used for database null values, it represent the absence of value, otherwise NULL.

Dominic Goulet
  • 7,983
  • 7
  • 28
  • 56
1

You should use DBNull

Alex Shnayder
  • 1,362
  • 1
  • 13
  • 24