Help with ADO and dynamic insert statement...

waldekO osuchw at ecn.ab.ca
Fri Jun 14 02:03:40 EDT 2002


You should at least post a traceback if you expect a resonable answer
to your question.
 
candiazoo at attbi.com wrote in message news:<3d0826ec.240888125 at netnews.attbi.com>...
> I have a program written in VB that creates an ado COMMAND object, sets the text
> to a dynamic sql string (insert into table (?, ?, ?, etc))...  it works in VB...
> this is my first foray into doing something similar with Python and it isn't
> working.  Could someone take a gander at this and tell me what I might be doing
> incorrectly?
> 
> Thanks!
> 
> Mike
> 
> ============================================
> segment of code below
> ============================================
> 
>     if status == SUCCESS:
>         #   Generate our dynamic insert statement, create new
>         #   ADODB connection and command objects which we'll
>         #   use to connect to our access database (via the
>         #   CatalogMDB DSN object)...
> 
>         sql = "insert into works (title, wrk_inst, trs_inst, aas_inst) " + \
>               "values (?, ?, ?, ?)"
>     
>         cnnTempDB = win32com.client.Dispatch('ADODB.Connection')
>         cmdInsert = win32com.client.Dispatch('ADODB.Command')
>         
>         cnnTempDB.Open(TEMP_DB)
>         cmdInsert.ActiveConnection = cnnTempDB
>         cmdInsert.CommandType = 1
>         cmdInsert.CommandText = sql
>         
>         if not rstOracle.EOF:
>             #   Let's bind up our dynamic sql statement...
>             
>             cmdInsert.Parameters.Append(cmdInsert.CreateParameter("title", 200,
> 1, len(rstOracle.Fields("title").Value), rstOracle.Fields("title").Value))
>             cmdInsert.Parameters.Append(cmdInsert.CreateParameter("wrk_inst",
> 131, 1, 4, rstOracle.Fields("wrk_inst").Value))
>             cmdInsert.Parameters.Append(cmdInsert.CreateParameter("trs_inst",
> 131, 1, 4, rstOracle.Fields("trs_inst").Value))
>             cmdInsert.Parameters.Append(cmdInsert.CreateParameter("aas_inst",
> 131, 1, 4, rstOracle.Fields("aas_inst").Value))
>             cmdInsert.Execute()
>             rstOracle.MoveNext()



More information about the Python-list mailing list