Thanks for the advice, I changed CommandType to 1 and worked but seems that there is a problem getting over the string copy&paste with the strXML.
I have changed the way I do this with the following:
Set objConn = CreateObject("ADODB.Connection")
objConn.Open("PROVIDER=SQLOLEDB;SERVER=TestServer; DATABASE=TestDB;UID=sa;PWD=;")
Set rsTitles = CreateObject("ADODB.Recordset")
rsTitles.Open "select * from Market FOR XML AUTO, ELEMENTS", objConn
szFile = "F:\thodoris\TestFile.xml"
rsTitles.Save szFile, adPersistXML
rsTitles.Close
objConn.Close
Set objConn = Nothing
But the
format of the xml file I am getting does not look at all like xml! Do you have any idea what might go wrong?!
Best Regards,
Theodore.
Quote:
quote:Originally posted by pgtips
You don't say what the error is, so all I can do is point out the few things that look strange to me:
1. the items SERVER and DATABASE in your connection string are usually referred to as Data Source and Initial Catalog
2. CommandType 4 is "stored procedure", but you are executing a SQL string so you want CommandType 1.
3. strXML = objStream.ReadText : shouldn't this line be *after* the SQL has been executed?
Finally, this property, objCmd.Properties("XML Root") = "whatever" is useful too because you don't get a root element by default with FOR XML queries.
hth
Phil
|