VB 2002 Freaking Out with Datasets!

  • Thread starter Thread starter Peter
  • Start date Start date
P

Peter

Hi!

I am frustrated! I spent a lot of time designing a custom dataset schema
(XSD file) using the Dataset designer. In my main form I had created an
instance of a typed dataset using that schema, and all was going well for
days. Now, tonight, I suddenly opened up the solution and 1) the dataset is
gone from the main form, and 2) I can't re-instantiate it. When I drag a new
dataset onto the control surface, my XSD file is no longer listed... I just
see (no datasets in project).

I've tried copying the contents of that file into a new dataset, with no
luck. Why would VB suddenly go berserk on me like this? And how can I
comvince it that, yes, there IS a dataset schema all ready to use?

---P
 
Peter said:
Hi!

I am frustrated! I spent a lot of time designing a custom dataset schema
(XSD file) using the Dataset designer. In my main form I had created an
instance of a typed dataset using that schema, and all was going well for
days. Now, tonight, I suddenly opened up the solution and 1) the dataset
is gone from the main form, and 2) I can't re-instantiate it. When I drag
a new dataset onto the control surface, my XSD file is no longer listed...
I just see (no datasets in project).

I've tried copying the contents of that file into a new dataset, with no
luck. Why would VB suddenly go berserk on me like this? And how can I
comvince it that, yes, there IS a dataset schema all ready to use?

Update on the problem: there is something wrong with the XSD file preventing
it from being turned into a dataset. It's giving me the error:

Invalid XPath selection inside field node. Cannot find: ID.

Is there any way to tell what line this is happening at? I am not very good
at reading these files (and I can't figure out why there is suddenly an
error... .NET generated this for me!). Most of this file (including the
table relations) worked not 24 hours ago.

In case it would help if I posted the entire XSD file, here it is:

***
<?xml version="1.0" encoding="utf-8" ?>
<xs:schema id="Papers" xmlns="" xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xs:element name="Papers" msdata:IsDataSet="true">
<xs:complexType>
<xs:choice maxOccurs="unbounded">
<xs:element name="Paper" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="ID" type="xs:int" minOccurs="1"
msdata:AutoIncrement="true" msdata:AutoIncrementSeed="0"
msdata:AutoIncrementStep="1" maxOccurs="1" />
<xs:element name="Size" type="xs:int" minOccurs="1" maxOccurs="1"
default="0" />
<xs:element name="Weight" type="xs:int" minOccurs="1" maxOccurs="1"
default="0" />
<xs:element name="Brand" type="xs:int" minOccurs="1" maxOccurs="1"
default="0" />
<xs:element name="PagesPerSet" type="xs:int" minOccurs="1"
maxOccurs="1" />
<xs:element name="Type" type="xs:int" minOccurs="1" maxOccurs="1"
default="0" />
<xs:element name="Color" type="xs:int" minOccurs="1"
maxOccurs="unbounded" default="0" />
<xs:element name="Finish" type="xs:int" minOccurs="1" maxOccurs="1"
default="0" />
<xs:element name="WholesalePrice" type="xs:double" minOccurs="1"
maxOccurs="1" default="0" />
<xs:element name="IsFree" type="xs:boolean" minOccurs="0" />
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="Size">
<xs:complexType>
<xs:sequence>
<xs:element name="ID" type="xs:int" maxOccurs="1" minOccurs="1"
msdata:AutoIncrement="true" msdata:AutoIncrementSeed="0"
msdata:AutoIncrementStep="1" />
<xs:element name="XInches" type="xs:double" maxOccurs="1"
minOccurs="1" />
<xs:element name="YInches" type="xs:double" minOccurs="1"
maxOccurs="1" />
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="Color">
<xs:complexType>
<xs:sequence>
<xs:element name="ID" type="xs:int" maxOccurs="1" minOccurs="1"
msdata:AutoIncrementSeed="0" msdata:AutoIncrementStep="1"
msdata:AutoIncrement="true" />
<xs:element name="Name" type="xs:string" minOccurs="1" maxOccurs="1"
/>
<xs:element name="Hex" type="xColor" minOccurs="1" maxOccurs="1" />
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="Weight">
<xs:complexType>
<xs:sequence>
<xs:element name="ID" type="xs:int" minOccurs="1" maxOccurs="1"
msdata:AutoIncrementSeed="0" msdata:AutoIncrementStep="1"
msdata:AutoIncrement="true" />
<xs:element name="Pounds" type="xs:int" minOccurs="1" maxOccurs="1"
/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="Brand">
<xs:complexType>
<xs:sequence>
<xs:element name="ID" type="xs:int" minOccurs="1" maxOccurs="1" />
<xs:element name="Name" type="xs:string" minOccurs="1" maxOccurs="1"
/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="Type">
<xs:complexType>
<xs:sequence>
<xs:element name="ID" type="xs:int" minOccurs="1" maxOccurs="1" />
<xs:element name="Name" type="xs:string" minOccurs="1" maxOccurs="1"
/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="Finish">
<xs:complexType>
<xs:sequence>
<xs:element name="ID" type="xs:int" minOccurs="1" maxOccurs="1" />
<xs:element name="Name" type="xs:string" minOccurs="1" maxOccurs="1"
/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:choice>
</xs:complexType>
<xs:key name="PaperKey" msdata:PrimaryKey="true">
<xs:selector xpath=".//Paper" />
<xs:field xpath="ID" />
</xs:key>
<xs:key name="SizeKey" msdata:PrimaryKey="true">
<xs:selector xpath=".//Size" />
<xs:field xpath="ID" />
</xs:key>
<xs:keyref name="PaperSize" refer="SizeKey"
msdata:AcceptRejectRule="Cascade" msdata:DeleteRule="Cascade"
msdata:UpdateRule="Cascade">
<xs:selector xpath=".//Paper" />
<xs:field xpath="Size" />
</xs:keyref>
<xs:key name="ColorKey" msdata:PrimaryKey="true">
<xs:selector xpath=".//Color" />
<xs:field xpath="ID" />
</xs:key>
<xs:keyref name="PaperColor" refer="ColorKey"
msdata:AcceptRejectRule="Cascade" msdata:UpdateRule="Cascade"
msdata:DeleteRule="Cascade">
<xs:selector xpath=".//Paper" />
<xs:field xpath="Color" />
</xs:keyref>
<xs:key name="WeightKey" msdata:PrimaryKey="true">
<xs:selector xpath=".//Weight" />
<xs:field xpath="ID" />
</xs:key>
<xs:keyref name="WeightPaper" refer="WeightKey"
msdata:AcceptRejectRule="Cascade" msdata:DeleteRule="Cascade"
msdata:UpdateRule="Cascade">
<xs:selector xpath=".//Paper" />
<xs:field xpath="Weight" />
</xs:keyref>
<xs:key name="BrandKey" msdata:PrimaryKey="true">
<xs:selector xpath=".//Brand" />
<xs:field xpath="ID" />
</xs:key>
<xs:keyref name="BrandPaper" refer="BrandKey"
msdata:AcceptRejectRule="Cascade" msdata:DeleteRule="Cascade"
msdata:UpdateRule="Cascade">
<xs:selector xpath=".//Paper" />
<xs:field xpath="Brand" />
</xs:keyref>
<xs:key name="TypeKey" msdata:PrimaryKey="true">
<xs:selector xpath=".//Type" />
<xs:field xpath="ID" />
</xs:key>
<xs:keyref name="TypePaper" refer="TypeKey"
msdata:AcceptRejectRule="Cascade" msdata:DeleteRule="Cascade"
msdata:UpdateRule="Cascade">
<xs:selector xpath=".//Paper" />
<xs:field xpath="Type" />
</xs:keyref>
<xs:key name="FinishKey" msdata:PrimaryKey="true">
<xs:selector xpath=".//Finish" />
<xs:field xpath="ID" />
</xs:key>
<xs:keyref name="FinishPaper" refer="FinishKey"
msdata:AcceptRejectRule="Cascade" msdata:DeleteRule="Cascade"
msdata:UpdateRule="Cascade">
<xs:selector xpath=".//Paper" />
<xs:field xpath="Finish" />
</xs:keyref>
</xs:element>
<xs:simpleType name="xColor">
<xs:restriction base="xs:string">
<xs:length value="6" />
<xs:pattern value="[0-9A-F]{6}" />
</xs:restriction>
</xs:simpleType>
</xs:schema>
 
Update on the problem: there is something wrong with the XSD file
preventing it from being turned into a dataset. It's giving me the error:

Invalid XPath selection inside field node. Cannot find: ID.

Is there any way to tell what line this is happening at? I am not very
good at reading these files (and I can't figure out why there is suddenly
an error... .NET generated this for me!). Most of this file (including the
table relations) worked not 24 hours ago.

I have nailed down the cause of the problem. I made the seemingly small
change of switching the maxOccurs of the Color element of table Paper to
unbounded (the previous value was 1). For some reason, that caused the
dataset parser to change that table element into a table of its own,
creating a conflict between itself and the other, separate table which I
manually created, also named Color.
 
Peter,

Mostly this kind of errors comes because that you have used the class name
again in your code.

Can you have a look for that.

Or deleteted it and added it again.

Cor
 
Cor Ligthert said:
Peter,

Mostly this kind of errors comes because that you have used the class name
again in your code.

Can you have a look for that.

Or deleteted it and added it again.

I did find the problem... I was trying to use foreign keys to define a
many-to-many relationship. I now know I can't do that. I don't know what I
can do instead, but I will probably learn that tomorrey.
 
Back
Top