Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Check IsDBNull for BigInt 2

Status
Not open for further replies.

ksbigfoot

Programmer
Apr 15, 2002
856
CA
My Primary Key of my table is of type BigInt.
I load my data into a DataReader and then I call my function to see if the field is Null:
Code:
CheckDBNullBigInt(dr, 0)
Here is my function code:
Code:
Public Shared Function CheckDBNullInt(ByVal DataReader As IDataReader, ByVal iValue As Int32) As Int32

  If Not DataReader.IsDBNull(iValue) Then
     Return DataReader.GetInt32(iValue)
  End If

  Return 0
End Function

I keep getting the message: "Specified cast is not valid" on the line Return DataReader.GetInt32(iValue).
If I change it to return a Int64, I get the following message: "Option Strict On disallows implicit conversions from Long to Integer."

I am not sure how to pass back a BigInt?
Could someone point me in the right direction.

Thanks
 
I would also use Int64 in that case (though I haven't taken the time to test it)

Code:
  Public Shared Function CheckDBNullInt(ByVal DataReader As IDataReader, ByVal iValue As Int32) As Int64

  If Not DataReader.IsDBNull(iValue) Then
     Return DataReader.GetInt64(iValue)
  End If

  Return converto.toInt64(0)
End Function
 
Thanks Mastakilla and SiriusBlackOp,
Star to you both. Thanks again Mastakilla, you code works perfectly.

ksbigfoot
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top