From: mercano (mercano@voila.fr)
Date: 17/06/2004 - 09:56
Bonjour. Cherchant le moyen d'extraire des données de SQL Server, au format
XML
j'en suis arrivé (bien malgré moi) à tester ADO sous visual basic.
A partir d'un exemple sur northwind (bdd sous sqlserver) je cherche à
exporter
un fichier xml valide pointant vers un schema xsd.
J'ai la fonction suivante:
-------------------------------------------------
Public Function ForXMLAutoQuery() Dim adoConn As New ADODB.Connection
Dim adoCmd As New ADODB.Command
Dim adoStream As New ADODB.Stream adoConn.Open strConnectionString
Set adoCmd.ActiveConnection = adoConn
adoCmd.CommandType = adCmdText
adoCmd.Properties("XML Root") = "Racine"
adoCmd.Properties("Mapping Schema") = "Result.xsd"
&nbs p;
adoCmd.CommandText = "select Customers.ContactName, " &_
"Customers.ContactTitle, " &_
"Customers.CompanyName, Customers.CustomerID," &_
"Orders.OrderID, Orders.OrderDate, Orders.ShippedDate, " &_
"[Order Details].UnitPrice, [Order Details].Quantity, " &_
"Products.ProductName , Products.UnitsInStock " &_
"From Customers, Orders, [Order Details], Products " &_
"Where Customers.CustomerID = Orders.CustomerID " &_
"and Orders.OrderID = [Order Details].OrderID " &_
"and [Order Details].ProductID = Products.ProductID " &_
&n bsp; "and Customers.CustomerID='GROSR' for XML AUTO"
adoStream.Open
adoCmd.Properties("Output Stream").Value = adoStream
adoCmd.Execute , , adExecuteStream
txtResults.Text = adoStream.ReadText
adoStream.SaveToFile ("Result.xml")
End Function
----------------------------------------------------------
elle produit un fichier XML bien formé avec entête
(http://le.gros.flop.free.fr/Tumo/Docs/Result.xml[1])mais je n'obtiens pas
dans ma balise racine le lien vers le schema correspondant.
Je voudrais obtenir:
<?xml version="1.0" encoding="utf-8" ?>
<Racine xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance[2]"
xsi:noNamespaceSchemaLocation="Result.xsd">
(...)
</Racine>
Quelqu'un connaitrait-il la fonction permettant cet ajout?
Merci
------------------------------------------
Faites un voeu et puis Voila ! www.voila.fr
--- Links ---
1 http://le.gros.flop.free.fr/Tumo/Docs/Result.xml
2 http://www.w3.org/2001/XMLSchema-instance
--
Devenez redacteur <XML>fr et contribuez au developpement du
xml francophone (http://xmlfr.org/infos/redacteurs/) !
Liste de diffusion "xml-tech@xmlfr.org" (http://xmlfr.org).
Cette liste est a votre disposition pour discuter en francais de
tout sujet technique lie a XML.
Pour resilier votre abonnement, envoyez un message contenant
la commande "unsubscribe" a xml-tech-request@xmlfr.org
(mailto:xml-tech-request@xmlfr.org?Subject=unsubscribe)
Archive générée par hypermail 2.1.3 le 30/06/2004 - 08:32 UTC
webmaster@xmlfr.org
|