ADO and COM contants

Discussion in 'Python' started by Boba, Feb 26, 2004.

  1. Boba

    Boba Guest

    Hi,
    I'm using python as the language in ASP pages to query a database ussing the
    com interface. I want to do a parameter query and I have to use constants
    like Null and Nothing. Does anyone know how to use the constants in Python?

    Part of the code:
    #------------------
    cmdQuery = win32com.client.Dispatch("ADODB.Command")
    cmdQuery.ActiveConnection = cnn
    cmdQuery.CommandText = "aStoredQuery"
    cmdQuery.CommandType = adCmdStoredProc

    # parameter: startdate
    qryParm = win32com.client.Dispatch("ADODB.Parameter")
    qryParm.Name = "parDateStart"
    qryParm.Type = adDBDate
    tmpDate =
    req.documentElement.selectSingleNode("//request_parDatBegin").text
    qryParm.Value = Null # at least sometimes
    cmdQuery.Parameters.Append(qryParm)
    #---------------
    end code

    Bob
     
    Boba, Feb 26, 2004
    #1
    1. Advertising

  2. Boba

    Roger Upole Guest

    You'll need to use makepy for the ADO library.
    Once you create an instance of the object, the constants will
    appear in win32com.client.constants, and then the code would
    look like
    cmdQuery.CommandType = win32com.client.constants.adCmdStoredProc

    For null parameters, most of the time you can use None and win32com will
    do the right thing.

    hth
    Roger

    "Boba" <> wrote in message
    news:403e4207$0$12847$...
    > Hi,
    > I'm using python as the language in ASP pages to query a database ussing

    the
    > com interface. I want to do a parameter query and I have to use constants
    > like Null and Nothing. Does anyone know how to use the constants in

    Python?
    >
    > Part of the code:
    > #------------------
    > cmdQuery = win32com.client.Dispatch("ADODB.Command")
    > cmdQuery.ActiveConnection = cnn
    > cmdQuery.CommandText = "aStoredQuery"
    > cmdQuery.CommandType = adCmdStoredProc
    >
    > # parameter: startdate
    > qryParm = win32com.client.Dispatch("ADODB.Parameter")
    > qryParm.Name = "parDateStart"
    > qryParm.Type = adDBDate
    > tmpDate =
    > req.documentElement.selectSingleNode("//request_parDatBegin").text
    > qryParm.Value = Null # at least sometimes
    > cmdQuery.Parameters.Append(qryParm)
    > #---------------
    > end code
    >
    > Bob
    >
    >
     
    Roger Upole, Feb 28, 2004
    #2
    1. Advertising

  3. Boba

    Boba Guest

    Roger,

    Thanks. You gave me more answer than I'd asked for. I think I solved the
    problem with the
    constants by adjusting the adovbs.inc file so that it contains constants
    that python
    understands. But there is no Null and no Nothing constant. I'll try your
    suggestion
    and use None.
    Douglas Savitsky mailed me saying that they should show up as
    win32com.client.constants.Null
    and win32com.client.constants.Nothing. At least the should be in the file
    that makepy
    generates. They don't.

    Bob Ambrosius


    Roger Upole <> schreef in berichtnieuws
    4040e17c_1@127.0.0.1...
    > You'll need to use makepy for the ADO library.
    > Once you create an instance of the object, the constants will
    > appear in win32com.client.constants, and then the code would
    > look like
    > cmdQuery.CommandType = win32com.client.constants.adCmdStoredProc
    >
    > For null parameters, most of the time you can use None and win32com will
    > do the right thing.
    >
    > hth
    > Roger
    >
    > "Boba" <> wrote in message
    > news:403e4207$0$12847$...
    > > Hi,
    > > I'm using python as the language in ASP pages to query a database ussing

    > the
    > > com interface. I want to do a parameter query and I have to use

    constants
    > > like Null and Nothing. Does anyone know how to use the constants in

    > Python?
    > >
    > > Part of the code:
    > > #------------------
    > > cmdQuery = win32com.client.Dispatch("ADODB.Command")
    > > cmdQuery.ActiveConnection = cnn
    > > cmdQuery.CommandText = "aStoredQuery"
    > > cmdQuery.CommandType = adCmdStoredProc
    > >
    > > # parameter: startdate
    > > qryParm = win32com.client.Dispatch("ADODB.Parameter")
    > > qryParm.Name = "parDateStart"
    > > qryParm.Type = adDBDate
    > > tmpDate =
    > > req.documentElement.selectSingleNode("//request_parDatBegin").text
    > > qryParm.Value = Null # at least sometimes
    > > cmdQuery.Parameters.Append(qryParm)
    > > #---------------
    > > end code
    > >
    > > Bob
    > >
    > >

    >
    >
     
    Boba, Mar 1, 2004
    #3
    1. Advertising

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. nita
    Replies:
    1
    Views:
    899
    Saravana
    Nov 20, 2004
  2. ronaldlee

    Transfer ADO Code to ADO.NET

    ronaldlee, Dec 17, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    487
    Kevin Spencer
    Dec 17, 2004
  3. Replies:
    0
    Views:
    1,337
  4. Stefan Ram
    Replies:
    5
    Views:
    480
  5. Kless

    Security in use of contants

    Kless, Aug 17, 2008, in forum: Ruby
    Replies:
    37
    Views:
    316
    David Masover
    Aug 20, 2008
Loading...

Share This Page