Your Get/Set statement is what I"m referring to. If the value it's
'getting' from the dataset returns DbNull, and you try returning it, it'll
blow up because the property is of Type String and it can't be converted.
Instead, you might want to do the IsDbNull check inside the Get statement
and if it is DbNull, return sting.Empty for instance.
Jim said:
William,
Thank you for the reply.
I tried the message box and got the same error. WorkPhone is a string.
What specifically do you mean by the 'accessor'? Are you referring to the
SQL statement that retrieves the data or the xml code for the dataset or the
MS generated .vb code that gets the values as properties from the dataset or
something else that I do not know about? I am including below the xml, the
sql statement for the fill, and a snippet from the code that retrieves the
data from the dataset. The error 13 is generated furhter down in the code
in the same subroutine that does the fill.
We may have a very basic misunderstanding of the proper usage of the
development environment to define datasets.
We use an SQLDataAdapter and reconfigure the GenAdapter
selectcommand.commandtext depending on the data we are retrieving. The
dataset has been defined by setting the adapter's select command, then
generating the dataset. At execution time we do a fill of the appropriate
dataset. Here is a copy of the xml from one of the datasets that we are
having trouble with.
<?xml version="1.0" standalone="yes" ?><xs:schema id="Clinics" targetNamespace="
http://www.tempuri.org/Clinics.xsd"
xmlns:mstns="
http://www.tempuri.org/Clinics.xsd"
xmlns:xs="
http://www.w3.org/2001/XMLSchema"
xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"
attributeFormDefault="qualified" elementFormDefault="qualified"><xs:element
name="Clinics" msdata:IsDataSet="true"><xs:complexType><xs:choice
maxOccurs="unbounded"><xs:element
name="Clinics"><xs:complexType><xs:sequence><xs:element name="ClinicNum"
type="xs:short" /><xs:element name="ClinicID" type="xs:string" /><xs:element
name="ShortName" type="xs:string" /><xs:element name="LongName"
type="xs:string" /><xs:element name="Root" type="xs:short" /><xs:element
name="Group" type="xs:string" /><xs:element name="Discount" type="xs:string"
/><xs:element name="License" type="xs:string" /><xs:element name="Doctor"
type="xs:string" /><xs:element name="DirectorName" type="xs:string"
/><xs:element name="DirectorTitle" type="xs:string" /><xs:element
name="webURL" type="xs:string" /><xs:element name="AltContact"
type="xs:string" /><xs:element name="AltContactTitle" type="xs:string"
/><xs:element name="Billing" type="xs:string" /><xs:element name="Expr1"
type="xs:string" /><xs:element name="Expr2" type="xs:dateTime" /><xs:element
name="Expr3" type="xs:short" /><xs:element name="Expr4"
msdata:ReadOnly="true" msdata:AutoIncrement="true" type="xs:int"
/><xs:element name="Expr5" type="xs:int" /><xs:element name="BtBID"
type="xs:int" /><xs:element name="branch" type="xs:string" /><xs:element
name="addresstype" type="xs:string" /><xs:element name="addressline1"
type="xs:string" /><xs:element name="streetnum" type="xs:string"
/><xs:element name="Streetname" type="xs:string" /><xs:element name="Apt"
type="xs:string" /><xs:element name="City" type="xs:string" /><xs:element
name="State" type="xs:string" /><xs:element name="Postalcode"
type="xs:string" /><xs:element name="Latitude" type="xs:string"
/><xs:element name="Longitude" type="xs:string" /><xs:element name="County"
type="xs:string" /><xs:element name="Homephone" type="xs:string"
/><xs:element name="Workphone" type="xs:string" /><xs:element name="FAX"
type="xs:string" /><xs:element name="Pager" type="xs:string" /><xs:element
name="email" type="xs:string" /><xs:element name="altphone" type="xs:string"
/><xs:element name="AltFAX" type="xs:string" /><xs:element name="AltPager"
type="xs:string" /><xs:element name="altemail" type="xs:string"
/><xs:element name="Startdate" type="xs:dateTime" /><xs:element
name="Enddate" type="xs:dateTime" /><xs:element name="Entrydate"
type="xs:dateTime" /><xs:element name="EnteredBy" type="xs:short"
/></xs:sequence></xs:complexType></xs:element></xs:choice></xs:complexType><
xs:unique name="Constraint1" msdata
rimaryKey="true"><xs:selector