mxODBC

A

Andrew Chalk

What is wrong with the following attempt to perform an SQL INSERT? No error
is thrown but no data is inserted into table FRED in the database.
Especially odd is that SELECT statements work! The database is MS SQL Server
2000.

Thanks!

import mx.DateTime, mx.ODBC.Windows

if __name__ == '__main__':
rc = 0
connection = mx.ODBC.Windows.DriverConnect(
'dsn=CNB;userid=Administrator' ) # connect to database
cAddAction = connection.cursor()
ActionID = "12345"
ProcessID = 100
sAddActionQuery = "INSERT INTO FRED (ActionID, ProcessID) VALUES (%s,
%d)" % (ActionID, ProcessID)
print "ActionID=" + ActionID
print "ProcessID=" + str(ProcessID) + "<BR>"
try:
cAddAction.execute(sAddActionQuery)
except:
print "INSERT error<BR>"
cAddAction.close()
cAddAction = None
connection.close()
connection = None
 
?

=?ISO-8859-1?Q?Gerhard_H=E4ring?=

Andrew said:
What is wrong with the following attempt to perform an SQL INSERT? No error
is thrown but no data is inserted into table FRED in the database.
Especially odd is that SELECT statements work! The database is MS SQL Server
2000. [...]

You don't seem to commit the transaction. Invoke .commit() on the
connection object to do so.

-- Gerhard
 
A

Andrew Chalk

Thanks! You're a hero, Gerhard.

Gerhard Häring said:
Andrew said:
What is wrong with the following attempt to perform an SQL INSERT? No error
is thrown but no data is inserted into table FRED in the database.
Especially odd is that SELECT statements work! The database is MS SQL Server
2000. [...]

You don't seem to commit the transaction. Invoke .commit() on the
connection object to do so.

-- Gerhard
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,164
Messages
2,570,898
Members
47,440
Latest member
YoungBorel

Latest Threads

Top