[VB.NET] How to store/load XML schema internally...

  • Thread starter Thread starter pat
  • Start date Start date
P

pat

Group,

I need to have my schemas loaded for a dataset, but can't have .xsd
files in my finished program laying around for users to mess with.

Is there a way to store the schema programmatically (preferably as data
in classes in .dlls, or even simple strings), thus avoiding having to
load them from the fs?

TIA!

pat
:)
 
Cor,

Well, for one thing I need to avoid the overhead of a dataset infering
the schema, as there will be a LOT of data sent to the dataset.
Additionally, I need to enforce (validate?) the values coming in are
interpretted correctly, as subsequent processes will depend on it.

This all works fine from a file:

dsTest.ReadXMLSchema("C:|someSchema.xsd")

I'm trying to do it without external files of any kind (except for
dlls, if that is how it needs to be done).

TIA!

pat
:)
 
Add the xsd to your project and select its Build Action to "Embedded
Resource." This builds the file into the EXE (or DLL). You can pass it to
ReadXmlSchema like this:

ds.ReadXmlSchema(System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("MyApplication.MySchema.xsd"))

Where MyApplication is the root namespace of your project.

You can do this with all sorts of files... like text files, Word documents,
RTF files, what have you.

P.S.
Alternatively, you should probably be converting your xsd's to "Typed
Datasets." They have their schema "built-in."
 
Cor,

I like the website you have. I am just learning how to use Datasets and
DataViews more effectively, and I like your DataSet section!

CMM,

Your solution makes it sound simple! I'll try it out as soon as I can!
Now I have hope!

Thanks!

pat
:)
 
Back
Top