|
|
|
start date: Tue, 14 Aug 2007 10:58:32 +0200,
posted on: microsoft.public.dotnet.framework.aspnet
back
| Thread Index |
|
1
Morten Snedker
|
|
2
Ladislav Mrnka
|
|
3
Morten Snedker
|
Problem with Dataset.WriteXML
This is the code:
Try
Dim con As New
SqlConnection("server=comwirsql;database=comwirdirect;Trusted_Connection=yes")
Dim dGetData As SqlDataAdapter = New
SqlDataAdapter("sp_AccessUser2FTP", con)
dGetData.SelectCommand.CommandType =
Data.CommandType.StoredProcedure
Dim dDataset As New Data.DataSet
dGetData.Fill(dDataset)
With dDataset
.DataSetName = "AccessUser"
.WriteXml("E:\output.xml")
'.WriteXmlSchema("e:\output.xsd")
End With
dDataset.Dispose()
dGetData.Dispose()
Catch ex As Exception
Response.Write(ex.Message)
End Try
This creates:
<AccessUser>
<Table>
<Lastname>hans</Lastname>
<Emailaddress1 />
</Table>
....
How do I avoid the creation of the Table tag?
Regards /Snedker
Date:Tue, 14 Aug 2007 10:58:32 +0200
Author:
|
RE: Problem with Dataset.WriteXML
Hi,
DataSet is memory representation of collection of tables. Thus you will
always have some tag representing table in dataset. You can use DataTable
instead of DataSet to reduce number of tags in resulting xml.
Regards,
Ladislav
"Morten Snedker" wrote:
> This is the code:
>
> Try
> Dim con As New
> SqlConnection("server=comwirsql;database=comwirdirect;Trusted_Connection=yes")
> Dim dGetData As SqlDataAdapter = New
> SqlDataAdapter("sp_AccessUser2FTP", con)
> dGetData.SelectCommand.CommandType =
> Data.CommandType.StoredProcedure
>
> Dim dDataset As New Data.DataSet
> dGetData.Fill(dDataset)
>
> With dDataset
> .DataSetName = "AccessUser"
> .WriteXml("E:\output.xml")
> '.WriteXmlSchema("e:\output.xsd")
> End With
>
> dDataset.Dispose()
> dGetData.Dispose()
> Catch ex As Exception
> Response.Write(ex.Message)
> End Try
>
> This creates:
>
> <AccessUser>
> <Table>
> <Lastname>hans</Lastname>
> <Emailaddress1 />
> </Table>
> ....
>
> How do I avoid the creation of the Table tag?
>
> Regards /Snedker
>
Date:Tue, 14 Aug 2007 02:06:03 -0700
Author:
|
Re: Problem with Dataset.WriteXML
Thanks for input. Changed to datatable and all's well!
Regards /Snedker
Ladislav Mrnka skrev:
> Hi,
>
> DataSet is memory representation of collection of tables. Thus you will
> always have some tag representing table in dataset. You can use DataTable
> instead of DataSet to reduce number of tags in resulting xml.
>
> Regards,
> Ladislav
>
> "Morten Snedker" wrote:
>
>> This is the code:
>>
>> Try
>> Dim con As New
>> SqlConnection("server=comwirsql;database=comwirdirect;Trusted_Connection=yes")
>> Dim dGetData As SqlDataAdapter = New
>> SqlDataAdapter("sp_AccessUser2FTP", con)
>> dGetData.SelectCommand.CommandType =
>> Data.CommandType.StoredProcedure
>>
>> Dim dDataset As New Data.DataSet
>> dGetData.Fill(dDataset)
>>
>> With dDataset
>> .DataSetName = "AccessUser"
>> .WriteXml("E:\output.xml")
>> '.WriteXmlSchema("e:\output.xsd")
>> End With
>>
>> dDataset.Dispose()
>> dGetData.Dispose()
>> Catch ex As Exception
>> Response.Write(ex.Message)
>> End Try
>>
>> This creates:
>>
>> <AccessUser>
>> <Table>
>> <Lastname>hans</Lastname>
>> <Emailaddress1 />
>> </Table>
>> ....
>>
>> How do I avoid the creation of the Table tag?
>>
>> Regards /Snedker
>>
Date:Tue, 14 Aug 2007 11:40:23 +0200
Author:
|
|
|