views:

240

answers:

1

please tell me how to implement Nullable Parameter of type string in vb.net

Function:

sub savedetail(byval name as string, byval age as integer)
if name isnot nothing then
some work
end if
end sub

i am calling it like thing

savedetail(nothing,34) //here is giving me format exception

exception : System.FormatException: Input string was not in a correct format.

Now i am placing exect function .. please tell me where i am making mistake:

Function savedetails(ByVal db As DSLibrary.DataProviders.SqlProvider, ByVal name As String, ByVal cityId As Integer, ByVal addr1 As String, ByVal addr2 As String, ByVal phone As String, ByVal fax As String, ByVal zip As String, ByVal contactfname As String, ByVal contactlname As String, ByVal randomcode As String, ByVal reservationEmail As String, ByVal email As String, ByVal url As String, ByVal description As String, ByVal locationInfo As String, ByVal amenities As String, ByVal roomDetails As String, ByVal latitude As Double, ByVal longitude As Double, ByVal enabled As Integer, Optional ByVal hotelId As Integer = Nothing, Optional ByVal checkDuplicate As Boolean = True, Optional ByVal DSPartner As Integer = Nothing, Optional ByVal category As String = Nothing, Optional ByVal rating As Integer = Nothing) As Integer

calling:

savedetails(db, hotelname, 0, address, Nothing, Nothing, Nothing, postal, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, hotelinfo, Nothing, service, Nothing, Convert.ToDouble(lat), Convert.ToDouble(longi), 1, Convert.ToInt32(hotelid), False, dspartnerid)
+3  A: 

Errrhm. A string is nullable by default as it is a reference type.

Edit after you provided more info: One of the Convert.ToDouble() and Convert.ToInt32() are likely throwing this exception. Either use the debugger and set a breakpoint on the call and inspect the parameters for these conversions or move them outside the call.

Wim Hollebrandse
but its giving me error .... let me edit my question and u please have a look again
Rajesh Rolen- DotNet Developer
yes you are right... convet.todouble was throwing exception...
Rajesh Rolen- DotNet Developer