firstName.Text = GetStringFromReader("firstName", clientReader,
String.Empty)
public static function(byval columnName as string, byval dr as IDataRecord,
byval defaultValue as string) as string
if dr(columnName) is DBNull.Value then
return defaultValue
end if
return Convert.ToString(dr(columnName))
end function
..net 2.0 will support nullable types...yay!
Karl
--
MY ASP.Net tutorials
http://www.openmymind.net/
"Daniel Fisher(lennybacon)" <info@(removethis)lennybacon.com> wrote in
message news:...
> 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" <> wrote in message
> news:%...
> > 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.
> >
>
>