Re: Cast from type 'DBNull' to type 'String' is not valid.
From: Daniel Fisher\(lennybacon\) (info_at_(removethis)lennybacon.com)
Date: 12/15/04
- Next message: Jo Yoshida: "System.MissingFieldException: Field not found"
- Previous message: Juan T. Llibre [MVP]: "Re: Global.asax file"
- In reply to: tshad: "Cast from type 'DBNull' to type 'String' is not valid."
- Next in thread: Karl Seguin: "Re: Cast from type 'DBNull' to type 'String' is not valid."
- Reply: Karl Seguin: "Re: Cast from type 'DBNull' to type 'String' is not valid."
- Messages sorted by: [ date ] [ thread ]
Date: Wed, 15 Dec 2004 17:38:06 +0100
ClientReader.GetValue(0).ToString()
is not so nice cause you set the num of th column and not the name, but
works.
-- Daniel Fisher(lennybacon) MCP ASP.NET C# Blog: http://www.lennybacon.com/ "tshad" <tscheiderich@ftsolutions.com> wrote in message news:%232b0YNs4EHA.1524@TK2MSFTNGP09.phx.gbl... > The error I am getting is: > > ******************************************************************* > Exception Details: System.InvalidCastException: Cast from type 'DBNull' to > type 'String' is not valid. > > Source Error: > > Line 144: firstName.text = ClientReader("firstName") > Line 145: lastName.text = ClientReader("lastName") > Line 146: middleName.text = ClientReader("middleName") <------ > Line 147: fullName.text = ClientReader("fullName") > Line 148: address1.text = ClientReader("address1") > ******************************************************************* > > The code I am getting the error in is: > > if ClientReader.Read then > applicantID.text = ClientReader("applicantID") > firstName.text = ClientReader("firstName") > lastName.text = ClientReader("lastName") > middleName.text = ClientReader("middleName") > fullName.text = ClientReader("fullName") > allowedWorkUS.text = ClientReader("allowedWorkUS") > end if > > How would I best do this? Do I have to check for null for each of my > variables everytime I read a record? > > Thanks, > > Tom. >
- Next message: Jo Yoshida: "System.MissingFieldException: Field not found"
- Previous message: Juan T. Llibre [MVP]: "Re: Global.asax file"
- In reply to: tshad: "Cast from type 'DBNull' to type 'String' is not valid."
- Next in thread: Karl Seguin: "Re: Cast from type 'DBNull' to type 'String' is not valid."
- Reply: Karl Seguin: "Re: Cast from type 'DBNull' to type 'String' is not valid."
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|