473,386 Members | 1,694 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Export Access query as XML and read into dotnet DataSet??

Hi,

(I'm new to XML)

I can export data from Access as an XML file (with schema integrated in
the XML file). I can read it into a DotNet DataSet, but the schema is
not correct that is - I do not get the right columns.

Is there some kinda trick to convert the XML to a
DotNet-DataSet-readbable file??

Thanks!

M O J O
Nov 12 '05 #1
9 6745
Why don't you just query Access directly from .NET?
Why go through the step of exporting to XML, then trying to read it in?

what are you really trying to accomplish?

"M O J O" <mojo@_no_spam_delete_this_newwebsolutions.dk> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
Hi,

(I'm new to XML)

I can export data from Access as an XML file (with schema integrated in
the XML file). I can read it into a DotNet DataSet, but the schema is
not correct that is - I do not get the right columns.

Is there some kinda trick to convert the XML to a
DotNet-DataSet-readbable file??

Thanks!

M O J O

Nov 12 '05 #2
You best best is to use ADO.NET to connect to Access rather than use its XML
file. In the future, this may be different, but the Access format is not the
same as the DataSet format of XML.

If you have to move from Access to DataSet, I would look at creating a XSLT
stylesheet and transforming to the DataSet XML using it. This is a much more
reuseable method of conversion. Not sure if anyone has already tackled this
monster, so I would do a search before writing it myself.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

************************************************** ********************
Think Outside the Box!
************************************************** ********************
"M O J O" <mojo@_no_spam_delete_this_newwebsolutions.dk> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
Hi,

(I'm new to XML)

I can export data from Access as an XML file (with schema integrated in
the XML file). I can read it into a DotNet DataSet, but the schema is
not correct that is - I do not get the right columns.

Is there some kinda trick to convert the XML to a
DotNet-DataSet-readbable file??

Thanks!

M O J O

Nov 12 '05 #3
Cor
Hi Mojo,

In addition to the other messages, when you want to use your access direct,
you can of course connect direct.

But when you want to use it as an export file I think that if you cannot
read an XML as a dataset you can always convert it using the XMLreader or
the LoadXML (the document object model).

A dataset is not that difficult to make although as it sometimes look.

Dim ds As New DataSet
Dim dt As New DataTable("Active")
dt.Columns.Add(New DataColumn("String", Type.GetType("System.String")))
dt.Columns.Add(New DataColumn("Ident", Type.GetType("System.Int32")))
Dim keys(0) As DataColumn
keys(0) = dt.Columns("Ident")
dt.PrimaryKey = keys
ds.Tables.Add(dt)

I hope this helps?

Cor
Nov 12 '05 #4
Hi Dino,

I'm creating a program that will accept data from several sources
(Access, Excel and so on).

So I want to use common interface to accept these sources.

Therefor I need to be able to easily read the XML file from access.

M O J O

Dino Chiesa [Microsoft] wrote:
Why don't you just query Access directly from .NET?
Why go through the step of exporting to XML, then trying to read it in?

what are you really trying to accomplish?

"M O J O" <mojo@_no_spam_delete_this_newwebsolutions.dk> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
Hi,

(I'm new to XML)

I can export data from Access as an XML file (with schema integrated in
the XML file). I can read it into a DotNet DataSet, but the schema is
not correct that is - I do not get the right columns.

Is there some kinda trick to convert the XML to a
DotNet-DataSet-readbable file??

Thanks!

M O J O



Nov 12 '05 #5
Please see my answer to Dino.

XSLT? I can hardly spell it! :o)

I just wanted it to be easy.

M O J O

Cowboy (Gregory A. Beamer) wrote:
You best best is to use ADO.NET to connect to Access rather than use its XML
file. In the future, this may be different, but the Access format is not the
same as the DataSet format of XML.

If you have to move from Access to DataSet, I would look at creating a XSLT
stylesheet and transforming to the DataSet XML using it. This is a much more
reuseable method of conversion. Not sure if anyone has already tackled this
monster, so I would do a search before writing it myself.


Nov 12 '05 #6
Thanks for Gregory, Dino and Cor's response.

Hi Mojo,

I agree with Gregory's idea to write an XSLT to transform the Xml to the
DataSet Xml. This is the simplest way if you want to use XML as the data
source, or you can connect to the Access file directly.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

Nov 12 '05 #7
Hi Mojo,

You can load xml directly into DataSet...
If the XSD schema is provided the DataSet would contain the schema.
If not it infers the schema from the Xml file...
and the columnNames will be the same as the element/attribute names in the
Xml file.

IF a Access Query is exported to Xml file, the structure is :
<dataroot>
<Products>
<ProductID>1</ProductID>
<ProductName>name1</ProductName>
</Products>
<Products>
</Products>
</dataroot>

Therefore DataSet will interpret as two tables, dataroot and Products.
But still you will be getting the elementNames as the columnNames.

C# Code:
========
DataSet ds = new DataSet();
ds.ReadXmlSchema(@"c:\products.xsd");
ds.ReadXml(@"C:\Products.xml");

Note: Access 2000 creates the XSD schema with old Schema Namespace, you
will have to change it to:
xmlns:xsd="http://www.w3.org/2001/XMLSchema"

When you load the schema with old namespace, DataSet throws an Exception.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

Nov 12 '05 #8
Access and Excel can both be queried via ADO.NET - using connection strings,
if I am not mistaken. this will get you a dataset, without having to first
"export to XML".

What's the "and so on"?

ADO.NET can do CSV, SQL server, other databases... ?

"M O J O" <mojo@_no_spam_delete_this_newwebsolutions.dk> wrote in message
news:OI**************@TK2MSFTNGP11.phx.gbl...
Hi Dino,

I'm creating a program that will accept data from several sources
(Access, Excel and so on).

So I want to use common interface to accept these sources.

Therefor I need to be able to easily read the XML file from access.

M O J O

Dino Chiesa [Microsoft] wrote:
Why don't you just query Access directly from .NET?
Why go through the step of exporting to XML, then trying to read it in?

what are you really trying to accomplish?

"M O J O" <mojo@_no_spam_delete_this_newwebsolutions.dk> wrote in message news:%2****************@TK2MSFTNGP10.phx.gbl...
Hi,

(I'm new to XML)

I can export data from Access as an XML file (with schema integrated in
the XML file). I can read it into a DotNet DataSet, but the schema is
not correct that is - I do not get the right columns.

Is there some kinda trick to convert the XML to a
DotNet-DataSet-readbable file??

Thanks!

M O J O


Nov 12 '05 #9
On Thu, 11 Dec 2003 20:05:06 +0100, M O J O <mojo@_no_spam_delete_this_newwebsolutions.dk> wrote:

¤ Hi Dino,
¤
¤ I'm creating a program that will accept data from several sources
¤ (Access, Excel and so on).
¤
¤ So I want to use common interface to accept these sources.
¤
¤ Therefor I need to be able to easily read the XML file from access.
¤
¤ M O J O
¤
¤ Dino Chiesa [Microsoft] wrote:
¤ > Why don't you just query Access directly from .NET?
¤ > Why go through the step of exporting to XML, then trying to read it in?
¤ >
¤ > what are you really trying to accomplish?
¤ >
¤ > "M O J O" <mojo@_no_spam_delete_this_newwebsolutions.dk> wrote in message
¤ > news:%2****************@TK2MSFTNGP10.phx.gbl...
¤ >
¤ >>Hi,
¤ >>
¤ >>(I'm new to XML)
¤ >>
¤ >>I can export data from Access as an XML file (with schema integrated in
¤ >>the XML file). I can read it into a DotNet DataSet, but the schema is
¤ >>not correct that is - I do not get the right columns.
¤ >>
¤ >>Is there some kinda trick to convert the XML to a
¤ >>DotNet-DataSet-readbable file??
¤ >>

I don't see the need for ADO here. Access, Excel, dBase, etc can all be queried directly from
ADO.NET (with the ODBC and OLEDB namespaces) using the same ODBC and OLEDB connections that are used
under ADO.
Paul ~~~ pc******@ameritech.net
Microsoft MVP (Visual Basic)
Nov 12 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

49
by: Relaxin | last post by:
It is just me or has MS created some of the worst ways to access and display data? You can use a DataSet, but if you want to sort or filter the data to must use a DataView which is created from...
1
by: Charlie | last post by:
Hello, I have data in an Access table that I would like to export to multiple HTML tables. I would like to split the data in the Access table (about 92,000 records) into multiple HTML...
4
by: Hans [DiaGraphIT] | last post by:
Hi! I want to export a dataset to an excel file. I found following code on the net... ( http://www.codeproject.com/csharp/Export.asp ) Excel.ApplicationClass excel = new ApplicationClass();...
8
by: M O J O | last post by:
Hi, (I'm new to XML) I can export data from Access as an XML file (with schema integrated in the XML file). I can read it into a DotNet DataSet, but the schema is not correct that is - I do...
3
by: BobAchgill | last post by:
I am trying to read in a xml file that I exported from my MSAccess table using the following lines of code but it bombs. Is this the right code? Is there a way to get a clean export from Access...
9
by: dennist685 | last post by:
I created a web project named 'Access' in C:\Inetpub\wwwroot\Access and dropped an .mdb there. I dragged a DetailView to the form, configured it to show two fields of a table, and got...
12
by: Selva Chinnasamy | last post by:
Hi I am using batch commands against Ms-Access and getting an error Message "Characters found after end of SQL statement." String Here is my sql Dim str_screens As String = "Select * from Screens...
1
by: smaczylo | last post by:
Hello, I've recently been asked to work with Microsoft Access, and while I feel quite comfortable with Excel, I'm at a complete loss with databases. If someone could help me with this issue I'm...
1
by: rhbourne | last post by:
Hello, I'm doing something wrong here, and it's driving me nuts. A very strange thing is happening with a query that populates an XML export function. 1. I have a query and its XML export...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.