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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem with System.InvalidCastException:

Status
Not open for further replies.

neomax

Programmer
Jul 1, 2006
29
BG
Exception Details: System.InvalidCastException: Cast from type 'DBNull' to type 'String' is not valid.


Line 313: end if
Line 314: publishername = "N/A"
Line 315: if rs.item("publisherid")>0 then publishername = rs.item("publishername")
Line 316: articleid=rs.item("articleid")
Line 317: %>


Source File: somefile.aspx
Line: 315

What it can be?

 
Code:
if rs.item("publisherid")>0 then publishername = rs.item("publishername")
Line 316:    articleid=rs.item("articleid")

one of those columns have a null value.

2 ways to solve this:
a. At the query end (use isNull function)
b. .NET end (check each column is of type dbnull)

Known is handfull, Unknown is worldfull
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top