porting VB code to C++ 
Author Message
 porting VB code to C++

Hi all!

I have a VB sample code (see below) which uses ADO to retrieve some XML data
from SQL Server. Now I'd like to port this code to C++, but I do not know
how to do it. In my C++ application I'm using CCommand class - how can I set
the property "Mapping schema" as it's done in the VB sample application? I
know how to set the dialect, but I do not know how two set the required
property.

Regards & Thanks

Markus

Sample code:
--------------

    Dim adoConn     As New ADODB.Connection
    Dim adoCmd      As New ADODB.Command
    Dim adoStream   As New ADODB.Stream

    adoConn.Open "provider=sqlxmloledb;data " & _
         provider=sqloledb;Server=(local);Database=northwind;UID=sa;PWD=;"
    Set adoCmd.ActiveConnection = adoConn
    adoCmd.CommandType = adCmdText
    adoCmd.Dialect = "{EC2A4293-E898-11D2-B1B7-00C04F680C56}"
    adoCmd.Properties("Mapping Schema") = "customers.xsd"

    adoStream.Open
    adoCmd.Properties("Output Stream").Value = adoStream
    adoCmd.Execute , , adExecuteStream

    Debug.Print adoStream.ReadText



Thu, 14 Oct 2004 05:22:51 GMT  
 porting VB code to C++
Kopp,

Setting dynamic properties on an ADO class is done by accessing the Properties
collection.   Something like the following might work:
adoCmd.Properties("Mapping Schema") = _bstr_t(L""customers.xsd");

best regards,
Roy Fine

Quote:

> Hi all!

> I have a VB sample code (see below) which uses ADO to retrieve some XML data
> from SQL Server. Now I'd like to port this code to C++, but I do not know
> how to do it. In my C++ application I'm using CCommand class - how can I set
> the property "Mapping schema" as it's done in the VB sample application? I
> know how to set the dialect, but I do not know how two set the required
> property.

> Regards & Thanks

> Markus

> Sample code:
> --------------

>     Dim adoConn     As New ADODB.Connection
>     Dim adoCmd      As New ADODB.Command
>     Dim adoStream   As New ADODB.Stream

>     adoConn.Open "provider=sqlxmloledb;data " & _
>          provider=sqloledb;Server=(local);Database=northwind;UID=sa;PWD=;"
>     Set adoCmd.ActiveConnection = adoConn
>     adoCmd.CommandType = adCmdText
>     adoCmd.Dialect = "{EC2A4293-E898-11D2-B1B7-00C04F680C56}"
>     adoCmd.Properties("Mapping Schema") = "customers.xsd"

>     adoStream.Open
>     adoCmd.Properties("Output Stream").Value = adoStream
>     adoCmd.Execute , , adExecuteStream

>     Debug.Print adoStream.ReadText



Thu, 14 Oct 2004 06:36:40 GMT  
 porting VB code to C++
Hi Roy!

In my C++ code I'm not using ADO, I use OLE DB. I use a CCommand class to
send my commands - but CCommand does not have "Properties" that I can set.

Regards

Markus



Quote:
> Kopp,

> Setting dynamic properties on an ADO class is done by accessing the
Properties
> collection.   Something like the following might work:
> adoCmd.Properties("Mapping Schema") = _bstr_t(L""customers.xsd");

> best regards,
> Roy Fine


> > Hi all!

> > I have a VB sample code (see below) which uses ADO to retrieve some XML
data
> > from SQL Server. Now I'd like to port this code to C++, but I do not
know
> > how to do it. In my C++ application I'm using CCommand class - how can I
set
> > the property "Mapping schema" as it's done in the VB sample application?
I
> > know how to set the dialect, but I do not know how two set the required
> > property.

> > Regards & Thanks

> > Markus

> > Sample code:
> > --------------

> >     Dim adoConn     As New ADODB.Connection
> >     Dim adoCmd      As New ADODB.Command
> >     Dim adoStream   As New ADODB.Stream

> >     adoConn.Open "provider=sqlxmloledb;data " & _

provider=sqloledb;Server=(local);Database=northwind;UID=sa;PWD=;"

- Show quoted text -

Quote:
> >     Set adoCmd.ActiveConnection = adoConn
> >     adoCmd.CommandType = adCmdText
> >     adoCmd.Dialect = "{EC2A4293-E898-11D2-B1B7-00C04F680C56}"
> >     adoCmd.Properties("Mapping Schema") = "customers.xsd"

> >     adoStream.Open
> >     adoCmd.Properties("Output Stream").Value = adoStream
> >     adoCmd.Execute , , adExecuteStream

> >     Debug.Print adoStream.ReadText



Thu, 14 Oct 2004 16:21:26 GMT  
 porting VB code to C++
Kopp,

Yes - the CCommand **does** have properties that you can set.  Please have a
look at the CCommand::Open method.  All properties that you set there must
belong to the Rowset property group.

"Mapping Schema" is the ADO name of the property.  The OLE DB specifier is
SSPROP_STREAM_MAPPINGSCHEMA.

For more information, search MSDN for SSPROP_STREAM_MAPPINGSCHEMA and have a
look at the KB Artivle Q272177.

All the best,
Roy Fine

Quote:

> Hi Roy!

> In my C++ code I'm not using ADO, I use OLE DB. I use a CCommand class to
> send my commands - but CCommand does not have "Properties" that I can set.

> Regards

> Markus



> > Kopp,

> > Setting dynamic properties on an ADO class is done by accessing the
> Properties
> > collection.   Something like the following might work:
> > adoCmd.Properties("Mapping Schema") = _bstr_t(L""customers.xsd");

> > best regards,
> > Roy Fine


> > > Hi all!

> > > I have a VB sample code (see below) which uses ADO to retrieve some XML
> data
> > > from SQL Server. Now I'd like to port this code to C++, but I do not
> know
> > > how to do it. In my C++ application I'm using CCommand class - how can I
> set
> > > the property "Mapping schema" as it's done in the VB sample application?
> I
> > > know how to set the dialect, but I do not know how two set the required
> > > property.

> > > Regards & Thanks

> > > Markus

> > > Sample code:
> > > --------------

> > >     Dim adoConn     As New ADODB.Connection
> > >     Dim adoCmd      As New ADODB.Command
> > >     Dim adoStream   As New ADODB.Stream

> > >     adoConn.Open "provider=sqlxmloledb;data " & _

> provider=sqloledb;Server=(local);Database=northwind;UID=sa;PWD=;"
> > >     Set adoCmd.ActiveConnection = adoConn
> > >     adoCmd.CommandType = adCmdText
> > >     adoCmd.Dialect = "{EC2A4293-E898-11D2-B1B7-00C04F680C56}"
> > >     adoCmd.Properties("Mapping Schema") = "customers.xsd"

> > >     adoStream.Open
> > >     adoCmd.Properties("Output Stream").Value = adoStream
> > >     adoCmd.Execute , , adExecuteStream

> > >     Debug.Print adoStream.ReadText



Thu, 14 Oct 2004 23:16:42 GMT  
 porting VB code to C++
Hi Roy!

Thanks again ... I think the articles I found might be very useful :-)

Regards

Markus



Quote:
> Kopp,

> Yes - the CCommand **does** have properties that you can set.  Please have
a
> look at the CCommand::Open method.  All properties that you set there must
> belong to the Rowset property group.

> "Mapping Schema" is the ADO name of the property.  The OLE DB specifier is
> SSPROP_STREAM_MAPPINGSCHEMA.

> For more information, search MSDN for SSPROP_STREAM_MAPPINGSCHEMA and have
a
> look at the KB Artivle Q272177.

> All the best,
> Roy Fine


> > Hi Roy!

> > In my C++ code I'm not using ADO, I use OLE DB. I use a CCommand class
to
> > send my commands - but CCommand does not have "Properties" that I can
set.

> > Regards

> > Markus



> > > Kopp,

> > > Setting dynamic properties on an ADO class is done by accessing the
> > Properties
> > > collection.   Something like the following might work:
> > > adoCmd.Properties("Mapping Schema") = _bstr_t(L""customers.xsd");

> > > best regards,
> > > Roy Fine


> > > > Hi all!

> > > > I have a VB sample code (see below) which uses ADO to retrieve some
XML
> > data
> > > > from SQL Server. Now I'd like to port this code to C++, but I do not
> > know
> > > > how to do it. In my C++ application I'm using CCommand class - how
can I
> > set
> > > > the property "Mapping schema" as it's done in the VB sample
application?
> > I
> > > > know how to set the dialect, but I do not know how two set the
required
> > > > property.

> > > > Regards & Thanks

> > > > Markus

> > > > Sample code:
> > > > --------------

> > > >     Dim adoConn     As New ADODB.Connection
> > > >     Dim adoCmd      As New ADODB.Command
> > > >     Dim adoStream   As New ADODB.Stream

> > > >     adoConn.Open "provider=sqlxmloledb;data " & _

> > provider=sqloledb;Server=(local);Database=northwind;UID=sa;PWD=;"
> > > >     Set adoCmd.ActiveConnection = adoConn
> > > >     adoCmd.CommandType = adCmdText
> > > >     adoCmd.Dialect = "{EC2A4293-E898-11D2-B1B7-00C04F680C56}"
> > > >     adoCmd.Properties("Mapping Schema") = "customers.xsd"

> > > >     adoStream.Open
> > > >     adoCmd.Properties("Output Stream").Value = adoStream
> > > >     adoCmd.Execute , , adExecuteStream

> > > >     Debug.Print adoStream.ReadText



Sat, 16 Oct 2004 23:25:00 GMT  
 porting VB code to C++
Hi Roy!

I found a useful knowledge base article
(http://support.microsoft.com/default.aspx?scid=kb;EN-US;q272177) -
unfortunately the sample only works for XDR schema files, but I'd like to
use a XSD schema file for my purposes. Do you know what I must change in the
code to enable XSD support?

Another problem is the output XML I retrieve when running the sample against
my database. The retrieved XML string contains several faulty characters
within the XML tags. For example, some tag names always contain these chars:
"H " - so the XML I retrieve is invalid due to this characters. Do you know
whar might cause the problem?

Regards

Markus



Quote:
> Kopp,

> Yes - the CCommand **does** have properties that you can set.  Please have
a
> look at the CCommand::Open method.  All properties that you set there must
> belong to the Rowset property group.

> "Mapping Schema" is the ADO name of the property.  The OLE DB specifier is
> SSPROP_STREAM_MAPPINGSCHEMA.

> For more information, search MSDN for SSPROP_STREAM_MAPPINGSCHEMA and have
a
> look at the KB Artivle Q272177.

> All the best,
> Roy Fine


> > Hi Roy!

> > In my C++ code I'm not using ADO, I use OLE DB. I use a CCommand class
to
> > send my commands - but CCommand does not have "Properties" that I can
set.

> > Regards

> > Markus



> > > Kopp,

> > > Setting dynamic properties on an ADO class is done by accessing the
> > Properties
> > > collection.   Something like the following might work:
> > > adoCmd.Properties("Mapping Schema") = _bstr_t(L""customers.xsd");

> > > best regards,
> > > Roy Fine


> > > > Hi all!

> > > > I have a VB sample code (see below) which uses ADO to retrieve some
XML
> > data
> > > > from SQL Server. Now I'd like to port this code to C++, but I do not
> > know
> > > > how to do it. In my C++ application I'm using CCommand class - how
can I
> > set
> > > > the property "Mapping schema" as it's done in the VB sample
application?
> > I
> > > > know how to set the dialect, but I do not know how two set the
required
> > > > property.

> > > > Regards & Thanks

> > > > Markus

> > > > Sample code:
> > > > --------------

> > > >     Dim adoConn     As New ADODB.Connection
> > > >     Dim adoCmd      As New ADODB.Command
> > > >     Dim adoStream   As New ADODB.Stream

> > > >     adoConn.Open "provider=sqlxmloledb;data " & _

> > provider=sqloledb;Server=(local);Database=northwind;UID=sa;PWD=;"
> > > >     Set adoCmd.ActiveConnection = adoConn
> > > >     adoCmd.CommandType = adCmdText
> > > >     adoCmd.Dialect = "{EC2A4293-E898-11D2-B1B7-00C04F680C56}"
> > > >     adoCmd.Properties("Mapping Schema") = "customers.xsd"

> > > >     adoStream.Open
> > > >     adoCmd.Properties("Output Stream").Value = adoStream
> > > >     adoCmd.Execute , , adExecuteStream

> > > >     Debug.Print adoStream.ReadText



Mon, 18 Oct 2004 01:03:55 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. porting VB code to C++

2. Porting C/C++ Source Code

3. Porting Pascal code to C++

4. Porting VB app to C++

5. I need testers for serial port comm DLL and alpha paging DLL (Delphi, C/C++, VB)

6. Porting VB app to C++

7. Porting VB app to C++

8. Porting VB app to C++

9. Porting VB 5.0 code to VB 6.0

10. Pls help me to convert these c++ code into vb

11. Creating a wrapper/dll for my C++ code to interface with VB

12. linking C++ codes to VB interface

 

 
Powered by phpBB® Forum Software