Home All Groups Group Topic Archive Search About

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

Author
11 Mar 2006 12:55 PM
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
Show quoteHide quote
:)

Author
11 Mar 2006 1:15 PM
Cor Ligthert [MVP]
Pat,

Why you need that schema. I have never used it.

Cor
Author
11 Mar 2006 4:17 PM
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
Show quoteHide quote
:)
Author
12 Mar 2006 7:13 AM
Cor Ligthert [MVP]
Pat,

You can make any dataset in code as the samples on our website are mostly
done.

http://www.vb-tips.com/default.aspx?ID=30d9d2fd-9f10-4928-b7c8-1def3152436f

What you miss on our site is the lenght to be set that is possible with

http://msdn2.microsoft.com/en-us/library/system.data.datacolumn.maxlength(VS.80).aspx

I hope this helps,

Cor
Author
13 Mar 2006 3:51 PM
pat
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
Show quoteHide quote
:)
Author
11 Mar 2006 5:37 PM
CMM
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."

--
-C. Moya
www.cmoya.com
Show quoteHide quote
"pat" <pat.trai***@gmail.com> wrote in message
news:1142081716.215090.75610@u72g2000cwu.googlegroups.com...
> 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
> :)
>