retrieve XML data from SQL server by using XSD mapping schema 
Author Message
 retrieve XML data from SQL server by using XSD mapping schema

Hi all!

In my C++ code I'm trying to retrieve XML data from SQL server by using an
XSD annotated mapping schema. I'm using a sample code that can be found at
http://www.*-*-*.com/ ;EN-US;q272177 which I
adapted slightly to my requirements. If I use a XSD mapping schema the
Execute() method of the ICommand fails with an E_FAIL. But if I use a XDR
schema everything works fine.

I wrote a little VB app using ADO to test my XSD schema - no errors occured
so my schema seems to be valid.

Can anybody tell me what I'm doing wrong? I can't image it's impossible to
use a XSD schema - so I guess I'm missing a certain parameter or whatever.
I'm using MDAC 2.6 SDK.

Regards & thanks in advance

Markus



Thu, 02 Dec 2004 02:03:46 GMT  
 retrieve XML data from SQL server by using XSD mapping schema
I believe the issue is the connection property is not being set, double
check you are setting the connection property to use SQLXML 3.0.

just after you open put this in.

conn->Properties->Item[L"SQLXML
Version"]->put_Value(_variant_t("SQLXML.3.0"));

HTH,

--
Dan Doris
Microsoft Corporation

This posting is provided "AS IS" with no warranties, and
confers no rights. You assume all risk for your use.
(c) 2002 Microsoft Corporation. All rights reserved.


Quote:
> Hi all!

> In my C++ code I'm trying to retrieve XML data from SQL server by using an
> XSD annotated mapping schema. I'm using a sample code that can be found at
> http://support.microsoft.com/default.aspx?scid=kb;EN-US;q272177 which I
> adapted slightly to my requirements. If I use a XSD mapping schema the
> Execute() method of the ICommand fails with an E_FAIL. But if I use a XDR
> schema everything works fine.

> I wrote a little VB app using ADO to test my XSD schema - no errors
occured
> so my schema seems to be valid.

> Can anybody tell me what I'm doing wrong? I can't image it's impossible to
> use a XSD schema - so I guess I'm missing a certain parameter or whatever.
> I'm using MDAC 2.6 SDK.

> Regards & thanks in advance

> Markus



Thu, 02 Dec 2004 10:03:38 GMT  
 retrieve XML data from SQL server by using XSD mapping schema
Hi Dan!

Thanks for your reply. Well, I do not use a connection object. I'm using a
CDataSource object to establish a database connection. After this is done, I
open a new session. After the session is opened, I execute the following
code to retrieve the XML result:

  USES_CONVERSION;
  CComPtr<ICommandProperties> pCommandProperties;
  CComPtr<ICommandText> pCommandText;
  _bstr_t m_path(_getcwd(NULL,512));

  // Create the Command
  CCommand<CNoAccessor,CNoRowset>::CreateCommand(m_session);

  // Set properties for getting the appropriate Stream
  CDBPropSet propset(DBPROPSET_SQLSERVERSTREAM);
  propset.AddProperty(SSPROP_STREAM_BASEPATH,(LPCWSTR) m_path);
  propset.AddProperty(SSPROP_STREAM_XMLROOT, OLESTR("MyRoot"));
  propset.AddProperty(SSPROP_STREAM_MAPPINGSCHEMA, OLESTR("all.xsd"));
  propset.AddProperty(SSPROP_STREAM_COMMANDTYPE, (long)
SSPROPVAL_COMMANDTYPE_REGULAR);

  hr = m_spCommand->QueryInterface(&pCommandProperties))
  hr = pCommandProperties->SetProperties(1,&propset))
  hr = m_spCommand->QueryInterface(&pCommandText))
  hr = pCommandText->SetCommandText(DBGUID_XPATH,
T2COLE((LPCTSTR)m_szCommand)))
  hr = m_spCommand->Execute(NULL, IID_ISequentialStream, NULL, NULL,
(IUnknown **) &pIXMLOutput );

It's the same code I found in the already mentioned sample - except the fact
that I'm using a XSD schema file.

Regards & thanks

Markus



Quote:
> I believe the issue is the connection property is not being set, double
> check you are setting the connection property to use SQLXML 3.0.

> just after you open put this in.

> conn->Properties->Item[L"SQLXML
> Version"]->put_Value(_variant_t("SQLXML.3.0"));

> HTH,

> --
> Dan Doris
> Microsoft Corporation

> This posting is provided "AS IS" with no warranties, and
> confers no rights. You assume all risk for your use.
> (c) 2002 Microsoft Corporation. All rights reserved.



> > Hi all!

> > In my C++ code I'm trying to retrieve XML data from SQL server by using
an
> > XSD annotated mapping schema. I'm using a sample code that can be found
at
> > http://support.microsoft.com/default.aspx?scid=kb;EN-US;q272177 which I
> > adapted slightly to my requirements. If I use a XSD mapping schema the
> > Execute() method of the ICommand fails with an E_FAIL. But if I use a
XDR
> > schema everything works fine.

> > I wrote a little VB app using ADO to test my XSD schema - no errors
> occured
> > so my schema seems to be valid.

> > Can anybody tell me what I'm doing wrong? I can't image it's impossible
to
> > use a XSD schema - so I guess I'm missing a certain parameter or
whatever.
> > I'm using MDAC 2.6 SDK.

> > Regards & thanks in advance

> > Markus



Fri, 03 Dec 2004 16:21:19 GMT  
 retrieve XML data from SQL server by using XSD mapping schema
Markus,

Please do NOT crosspost. It is considered bad form.

Besides, no one in this newsgroup can see the reply that you are responding
to.

Cheers,
Stuart
--
Stuart Celarier, Fern Creek, www.ferncrk.com
Consultant on .NET, Win32, C#, C++, COM, XML, XSLT and more.



Sat, 04 Dec 2004 03:21:24 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. using XSD as mapping schema

2. creating xml schema programmatically from an an xml file without using ADO.NET

3. How Retrieving SQL Server Binary Data

4. Retrieving SQL Server Binary Data

5. XML - using .xsd-files

6. Sample Published C/SQL Server Code to load star schema DWs

7. Sample Published C/SQL Server Code to load star schema DWs

8. how to read a xml without a valid schema using dataset

9. XSD Schema Definition Tool and extention

10. Help needed: problem in using odbc call to write binary data to SQL Server

11. Using ADO for SQL Server data access

12. Using ADO for SQL Server data access

 

 
Powered by phpBB® Forum Software