I am working on a legacy application that was built a couple years back....and for some reason one of the pages broke. Now please keep in mind Im not a guru when it comes to ASP.NET. I have a data grid/C1webgrid that I believe is giving me troubles. The reason I say that is sometimes I can access the page and all of my grids populate except for the very last one.
Now with said, I have checked my database and from what I can tell nothing looks null. I have search online for the error message, and I think I have an understanding as to what is happening. If Im not mistaken I am referencing a value of a datacolumn that is null. Now I am going to post my Stack Trace and then ask my question.
[InvalidCastException: Cast from type 'DBNull' to type 'Integer' is not valid.]
Microsoft.VisualBasic.CompilerServices.IntegerType.FromObject(Object Value) +819
ClientPortal.Team.GetSetUpData() +280
ClientPortal.Team.Page_Load(Object sender, EventArgs e) +612
System.Web.UI.Control.onload(EventArgs e) +67
System.Web.UI.Control.LoadRecursive() +35
System.Web.UI.Page.ProcessRequestMain() +750
Now my question is this....is my error occurring at the GetSetUpData function. The reason I ask is because Im not the best when it comes to reading these stack traces. Also I wanted to post this and try find the answer on my own before I post any code. Thanks in advance!
6 Replies - 1959 Views - Last Post: 11 April 2013 - 11:49 AM
#1
Cast from type 'DBNull' to type 'Integer' is not valid
Posted 27 February 2013 - 01:17 PM
Replies To: Cast from type 'DBNull' to type 'Integer' is not valid
#2
Re: Cast from type 'DBNull' to type 'Integer' is not valid
Posted 27 February 2013 - 01:18 PM
Correct.. it's in ClientPortal.Team.GetSetUpData() +280 when called from here:
ClientPortal.Team.Page_Load(Object sender, EventArgs e) +612
ClientPortal.Team.Page_Load(Object sender, EventArgs e) +612
#3
Re: Cast from type 'DBNull' to type 'Integer' is not valid
Posted 27 February 2013 - 01:31 PM
Kinda of a lame question but I have to ask because I don't know....what does +280 and +612 reference?
#4
Re: Cast from type 'DBNull' to type 'Integer' is not valid
Posted 27 February 2013 - 01:39 PM
They are some compiler used offset.. nothing to be used by you and me..
Typically if you have 'debugging' turned on you can get the specific file and line number.
Typically if you have 'debugging' turned on you can get the specific file and line number.
#5
Re: Cast from type 'DBNull' to type 'Integer' is not valid
Posted 27 February 2013 - 01:44 PM
Roger that!
#6
Re: Cast from type 'DBNull' to type 'Integer' is not valid
Posted 14 March 2013 - 09:53 AM
I suggest that you can check the following three points :
First: your code should look like this
Second: the property 「AllowDbNull」 in the datatable is 「true」
Third: to check that is there any comparison in the method 「GetSetUpData」? If it does. check whether the type is converted implicitly.
Just my simple thinkings.hope that it is helpful.
First: your code should look like this
DataTable.Rows[0][0]=DbNull.Value
Second: the property 「AllowDbNull」 in the datatable is 「true」
Third: to check that is there any comparison in the method 「GetSetUpData」? If it does. check whether the type is converted implicitly.
Just my simple thinkings.hope that it is helpful.
#7
Re: Cast from type 'DBNull' to type 'Integer' is not valid
Posted 11 April 2013 - 11:49 AM
I looked at my code and yes there is a line in there that is converting a Integer. That line of code is as follows.
Still not sure how to troubleshoot this thing. I checked my DB and I do allow nulls. Im going to try to hammer this thing out though. I will keep you guys posted.
Dim RegionCode As Integer = CStr(ClientID)
Still not sure how to troubleshoot this thing. I checked my DB and I do allow nulls. Im going to try to hammer this thing out though. I will keep you guys posted.
Page 1 of 1
|
|

New Topic/Question
Reply




MultiQuote






|