Win32 Extensions: problem with ADO.Command.Execute() options

Discussion in 'Python' started by Jason R. Coombs, Jul 2, 2003.

  1. I'm hoping this is a coding error on my part, but I've encountered a problem with parameters that I cannot understand. Perhaps someone out there might be willing to assist me with some suggestions.

    First, here is some VB code that correctly does what I want to do:

    --------------------------- begin cmdtest.vbs
    Dim cn
    Dim rs
    Dim cmd

    Set cn = CreateObject( "ADODB.Connection" )
    cn.Open( "Provider=SQLOLEDB;Data Source=(local);Initial Catalog=Environmental Monitoring;Integrated Security=SSPI" )

    Set rs = CreateObject( "ADODB.Stream" )
    rs.Open()

    Set cmd = CreateObject( "ADODB.Command" )

    cmd.ActiveConnection = cn
    cmd.Properties("Output Stream").Value = rs
    cmd.CommandText = "SELECT * FROM [Sources] for XML AUTO"

    cmd.Execute , , 1024 'adExecuteStream

    rs.Position = 0
    WScript.Echo rs.ReadText()
    --------------------------- end cmdtest.vbs

    Here is partial output I get:
    C:\>cscript cmdtest.vbs
    Microsoft (R) Windows Script Host Version 5.6
    Copyright (C) Microsoft Corporation 1996-2001. All rights reserved.

    <Sources ID="1" Name="South Asia" Type="7"/><Sources ID="2" Name="Japan" Type="2"/>...



    Now, if I attempt to do the same thing in python, it returns no output.
    ------------------------- begin cmdtest.py
    import ADO, sys

    cn = ADO.Connection()
    cn.Open( "Provider=SQLOLEDB;Data Source=(local);Initial Catalog=Environmental Monitoring;Integrated Security=SSPI" )

    rs = ADO.Stream()
    rs.Open()

    cmd = ADO.Command()

    cmd.ActiveConnection = cn
    cmd.Properties("Output Stream").Value = rs
    cmd.CommandText = "SELECT * FROM [Sources] for XML AUTO"

    cmd.Execute( Options = ADO.constants.adExecuteStream )

    rs.Position = 0
    sys.stdout.write( rs.ReadText() ) # prints nothing
    ------------------------- end cmdtest.py

    If I pass no parameters to cmd.Execute in the VBScript verison, I get no output. Other tests have further led me to conclude that the constant value 1024 is not being properly passed to ADO.Command.Execute in the Python version only.

    Here are some other points of information:
    a.. Using the literal 1024 in the Python code instead of the constant reference make no difference.
    b.. The VBScript code does not recognize adExecuteStream by name.
    c.. Using win32com.client.Dispatch( 'ADODB.*' ) to create the objects (instead of ADO.py created from make PY) yields the same results.
    d.. Using a different PROVIDER in the connection (such as SQLXMLOLEDB) will yield different results, but still indicates that the 'adExecuteStream' is not being set proprly.
    e.. I'm using "Microsoft ActiveX Data Objects 2.8 Library" for the ADO. I've tried using v2.5, but get identical results.
    f.. The first parameter to ADO.Command.Execute appears to be an [out] parameter, but the documentation is confusing and I haven't seen the first parameter used anywhere.

    Any insight into this problem would be most appreciated.

    Regards,
    Jason R. Coombs
    Sandia National Laboratories
     
    Jason R. Coombs, Jul 2, 2003
    #1
    1. Advertisements

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Lucas Cowald
    Replies:
    4
    Views:
    1,425
    Tohid
    Oct 23, 2003
  2. Lucas Cowald

    RUN/execute a Command-Line command from an ASP page

    Lucas Cowald, Oct 22, 2003, in forum: ASP .Net Building Controls
    Replies:
    1
    Views:
    449
    Genich
    Oct 22, 2003
  3. Lucas Cowald

    RUN/execute a Command-Line command from an ASP page.

    Lucas Cowald, Oct 22, 2003, in forum: ASP .Net Datagrid Control
    Replies:
    1
    Views:
    344
    Oliver
    Oct 22, 2003
  4. Lucas Cowald

    RUN/execute a Command-Line command from an ASP page.

    Lucas Cowald, Oct 22, 2003, in forum: ASP .Net Mobile
    Replies:
    0
    Views:
    280
    Lucas Cowald
    Oct 22, 2003
  5. Lucas Cowald

    RUN/execute a Command-Line command from an ASP page.

    Lucas Cowald, Oct 22, 2003, in forum: ASP .Net Security
    Replies:
    0
    Views:
    367
    Lucas Cowald
    Oct 22, 2003
  6. Lucas Cowald

    RUN/execute a Command-Line command from an ASP page.

    Lucas Cowald, Oct 22, 2003, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    261
    Lucas Cowald
    Oct 22, 2003
  7. Lucas Cowald

    RUN/execute a Command-Line command from an ASP page.

    Lucas Cowald, Oct 22, 2003, in forum: ASP .Net Web Services
    Replies:
    0
    Views:
    152
    Lucas Cowald
    Oct 22, 2003
  8. doug
    Replies:
    1
    Views:
    228
    Julia De Silva
    Jun 7, 2005
Loading...