readxmlschema from .xsd with primary key

R

Ryan Miller

I've created a .xsd file in VS.Net using the add>new item>XML Schema.

I created the fields and a primary key in this schema. However, when I use
the DataSet readsmlschema function I get a dataset with the proper fields,
but no primary key defined.

Has anyone successfully used this to load a dataset schema with primary
keys?

Thanks,
-Ryan
 
R

Ryan Miller

Ok, forget about it. This wasn't really what I wanted to do...I wanted to
be. a lumberjack.

Seriously though, I was going about this all wrong. What I was going for
was using the visual xml designer to design a schema that I could then read
into a dataset. If you do it this way primary keys (and I guess
relationships as well) need to be added in code by adding the datacolumn
array to the primary key property.

Instead, what I wanted to do was this:
Right click on the project, select add new item.
select Data Set, NOT XML Schema (gee I wonder how I could have gotten
confused)
That adds a xsd file to your project that you can manipulate exactly as you
did the xsd file created form the XML Schema.

NOTE: If you already have your schema created, but you used the add XML
Schema file. Don't worry, you can add a new DataSet as described above and
just copy/paste your tables across. However, you will need to delete and
recreate any Keys you've added. Otherwise they will not get added to the
final dataset.

NOTE2: Once you have your dataset created, you can right click in the
visual designer and select preview dataset. Then you can click + beside the
tables to see that the keys are actually defined.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top