Dim Timesemailed As Integer
Dim adv As New AdvanceLink(advlink)
If Not IsDBNull(adv.TimesEmailed) Then
Timesemailed = adv.TimesEmailed
Timesemailed = Timesemailed + 1
Else : Timesemailed = 1
End If
Const sSQL As String = "UPDATE tblAdvanceLink SET LastEmailed = @LastEmailed,TimesEmailed=@TimesEmailed WHERE ADVLinkID = @ADVLinkID"
Dim xSqlCommand As SqlCommand = New SqlCommand(sSQL, con)
Try
xSqlCommand.Parameters.Add("@LastEmailed", SqlDbType.DateTime)
xSqlCommand.Parameters("@LastEmailed").Value = DateTime.Today
xSqlCommand.Parameters.Add("@TimesEmailed", SqlDbType.Int)
xSqlCommand.Parameters("@TimesEmailed").Value = Timesemailed
xSqlCommand.Parameters.Add("@ADVLinkID", SqlDbType.Int)
xSqlCommand.Parameters("@ADVLinkID").Value = advlink
It's declared as Int64 in my properties just like my other integers. This is in my business logic file. The above code is the only place that writes this column data. I have it as an integer above but I tried changing it to int64 and that had no affect.
I wrote the same number to the table. (smallest integer)
Public Property TimesEmailed() As System.Int64
Get
Return _TimesEmailed
End Get
Set(ByVal Value As System.Int64)
_TimesEmailed = Value
End Set
End Property
I don't understand. If the column is a type integer, why doesn't isdbnull work on any type of integer including int64, int32, bigint, smallint ?
I have to be able to test for that. It is declared as int in the sql table. I have change it to int32 in the properties area of businesslogic. my debugger isn't stopping on this line.
I was able to resolve this by looking at another page on my site that does something similar with the updating of the table. I changing to a tinyint and it is now working:
Dim Numemails As Integer
Dim adv As New AdvanceLink(advlink)
If Not IsDBNull(adv.TimesEmailed) Then
Numemails = adv.TimesEmailed
Numemails = Numemails + 1
Else : Numemails = 1
End If
sking
Member
508 Points
1028 Posts
I wanted a 1 in my table - I got -2147483647
Aug 15, 2010 05:02 PM|LINK
Dim Timesemailed As Integer Dim adv As New AdvanceLink(advlink) If Not IsDBNull(adv.TimesEmailed) Then Timesemailed = adv.TimesEmailed Timesemailed = Timesemailed + 1 Else : Timesemailed = 1 End If Const sSQL As String = "UPDATE tblAdvanceLink SET LastEmailed = @LastEmailed,TimesEmailed=@TimesEmailed WHERE ADVLinkID = @ADVLinkID" Dim xSqlCommand As SqlCommand = New SqlCommand(sSQL, con) Try xSqlCommand.Parameters.Add("@LastEmailed", SqlDbType.DateTime) xSqlCommand.Parameters("@LastEmailed").Value = DateTime.Today xSqlCommand.Parameters.Add("@TimesEmailed", SqlDbType.Int) xSqlCommand.Parameters("@TimesEmailed").Value = Timesemailed xSqlCommand.Parameters.Add("@ADVLinkID", SqlDbType.Int) xSqlCommand.Parameters("@ADVLinkID").Value = advlinkSEO Software Tool | Link Exchange
mbanavige
All-Star
135167 Points
15505 Posts
ASPInsiders
Moderator
MVP
Re: I wanted a 1 in my table - I got -2147483647
Aug 15, 2010 07:52 PM|LINK
seems like the starting value for adv.TimesEmailed is Int32.MinValue which is -2,147,483,648
do you have some code somewhere that might be initializing that value to int32.minvalue ?
sking
Member
508 Points
1028 Posts
Re: I wanted a 1 in my table - I got -2147483647
Aug 16, 2010 03:53 AM|LINK
Hello Mike,
It's declared as Int64 in my properties just like my other integers. This is in my business logic file. The above code is the only place that writes this column data. I have it as an integer above but I tried changing it to int64 and that had no affect. I wrote the same number to the table. (smallest integer)
Public Property TimesEmailed() As System.Int64 Get Return _TimesEmailed End Get Set(ByVal Value As System.Int64) _TimesEmailed = Value End Set End PropertySEO Software Tool | Link Exchange
mbanavige
All-Star
135167 Points
15505 Posts
ASPInsiders
Moderator
MVP
Re: I wanted a 1 in my table - I got -2147483647
Aug 18, 2010 01:06 AM|LINK
looks like your local variable int is an int32. same with your sql type. might want to make them all the same just for consistency.
also, if adv.TimesEmailed is an Int64, then it can never be a DBNull. So the IsDBNull check isnt doing anything.
have you stepped into the code with your debugger to see what the values look like when its running?
sking
Member
508 Points
1028 Posts
Re: I wanted a 1 in my table - I got -2147483647
Aug 18, 2010 05:47 AM|LINK
I don't understand. If the column is a type integer, why doesn't isdbnull work on any type of integer including int64, int32, bigint, smallint ?
I have to be able to test for that. It is declared as int in the sql table. I have change it to int32 in the properties area of businesslogic. my debugger isn't stopping on this line.
SEO Software Tool | Link Exchange
sking
Member
508 Points
1028 Posts
Re: I wanted a 1 in my table - I got -2147483647
Aug 22, 2010 10:05 PM|LINK
I was able to resolve this by looking at another page on my site that does something similar with the updating of the table. I changing to a tinyint and it is now working:
Dim Numemails As Integer Dim adv As New AdvanceLink(advlink) If Not IsDBNull(adv.TimesEmailed) Then Numemails = adv.TimesEmailed Numemails = Numemails + 1 Else : Numemails = 1 End IfPrivate _TimesEmailed As System.Byte
SEO Software Tool | Link Exchange