ADO and COM contants

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Boba

    ADO and COM contants

    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("ADOD B.Command")
    cmdQuery.Active Connection = cnn
    cmdQuery.Comman dText = "aStoredQue ry"
    cmdQuery.Comman dType = adCmdStoredProc

    # parameter: startdate
    qryParm = win32com.client .Dispatch("ADOD B.Parameter")
    qryParm.Name = "parDateSta rt"
    qryParm.Type = adDBDate
    tmpDate =
    req.documentEle ment.selectSing leNode("//request_parDatB egin").text
    qryParm.Value = Null # at least sometimes
    cmdQuery.Parame ters.Append(qry Parm)
    #---------------
    end code

    Bob


  • Roger Upole

    #2
    Re: ADO and COM contants

    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.Comman dType = win32com.client .constants.adCm dStoredProc

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

    hth
    Roger

    "Boba" <b.ambrosius@hc cnet.nl> wrote in message
    news:403e4207$0 $12847$3a628fcd @reader1.nntp.h ccnet.nl...[color=blue]
    > Hi,
    > I'm using python as the language in ASP pages to query a database ussing[/color]
    the[color=blue]
    > 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[/color]
    Python?[color=blue]
    >
    > Part of the code:
    > #------------------
    > cmdQuery = win32com.client .Dispatch("ADOD B.Command")
    > cmdQuery.Active Connection = cnn
    > cmdQuery.Comman dText = "aStoredQue ry"
    > cmdQuery.Comman dType = adCmdStoredProc
    >
    > # parameter: startdate
    > qryParm = win32com.client .Dispatch("ADOD B.Parameter")
    > qryParm.Name = "parDateSta rt"
    > qryParm.Type = adDBDate
    > tmpDate =
    > req.documentEle ment.selectSing leNode("//request_parDatB egin").text
    > qryParm.Value = Null # at least sometimes
    > cmdQuery.Parame ters.Append(qry Parm)
    > #---------------
    > end code
    >
    > Bob
    >
    >[/color]


    Comment

    • Boba

      #3
      Re: ADO and COM contants

      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.Noth ing. At least the should be in the file
      that makepy
      generates. They don't.

      Bob Ambrosius


      Roger Upole <rupole@hotmail .com> schreef in berichtnieuws
      4040e17c_1@127. 0.0.1...[color=blue]
      > 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.Comman dType = win32com.client .constants.adCm dStoredProc
      >
      > For null parameters, most of the time you can use None and win32com will
      > do the right thing.
      >
      > hth
      > Roger
      >
      > "Boba" <b.ambrosius@hc cnet.nl> wrote in message
      > news:403e4207$0 $12847$3a628fcd @reader1.nntp.h ccnet.nl...[color=green]
      > > Hi,
      > > I'm using python as the language in ASP pages to query a database ussing[/color]
      > the[color=green]
      > > com interface. I want to do a parameter query and I have to use[/color][/color]
      constants[color=blue][color=green]
      > > like Null and Nothing. Does anyone know how to use the constants in[/color]
      > Python?[color=green]
      > >
      > > Part of the code:
      > > #------------------
      > > cmdQuery = win32com.client .Dispatch("ADOD B.Command")
      > > cmdQuery.Active Connection = cnn
      > > cmdQuery.Comman dText = "aStoredQue ry"
      > > cmdQuery.Comman dType = adCmdStoredProc
      > >
      > > # parameter: startdate
      > > qryParm = win32com.client .Dispatch("ADOD B.Parameter")
      > > qryParm.Name = "parDateSta rt"
      > > qryParm.Type = adDBDate
      > > tmpDate =
      > > req.documentEle ment.selectSing leNode("//request_parDatB egin").text
      > > qryParm.Value = Null # at least sometimes
      > > cmdQuery.Parame ters.Append(qry Parm)
      > > #---------------
      > > end code
      > >
      > > Bob
      > >
      > >[/color]
      >
      >[/color]


      Comment

      Working...