sql server - Read XML Schema and Data in .NET -


i'm using sql server , vb.net. in sql i'm using following:

select top 1 * tablename 1=0 xml auto, type, xmlschema 

to schema tablename. use

select * tablename id=1 xml, auto, type, elements xsinil, root('xml') 

to data row i'm interested.

if use following code in vb:

private ds new dataset  ds.readxmlschema("xmlschema.txt") 

i end ds containing 1 table correctly defined set of columns

if try:

ds.readxml("xmldata.txt") 

the code succeeds, don't have rows in table of dataset.

my question is, need in order read xml data created sql server datatable schema specified sql server.

  1. you need include xmlschema clause in second (data) query first (schema) query. if don't data output missing namespace , won't conform schema.

  2. you need specify target namespace schema qualifying xmlschema directive (e.g. xmlschema('http://tempuri.org')). if don't sql server generate namespace in each query, , may not match.

  3. you need make sure column lists , for xml clauses of 2 queries same. in example you've got xsinil specified in data query not in schema query.

so here need specify schema query

select top 1 * tablename  1=0  xml auto, type, elements xsinil, root('xml'), xmlschema('http://tempuri.org') 

and data query

select * tablename  xml auto, type, elements xsinil, root('xml'), xmlschema('http://tempuri.org') 

Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

ruby on rails - Seeing duplicate requests handled with Unicorn -