[code] ’ ## UPDATE BATCH :: SCORE + EST. TIME
DIM sql as String
sql = "SELECT intID FROM [KATbatch] WHERE intID = " + str(intLastID) + “;”
dim rs2 as RecordSet = dbDatabase.SQLSelect(sql)
I think I’m doing wrong when updating a post in the database.
Why not simply use the UPDATE command within SQL!?
I don’t love recordsets… I rather use simple SQL and the efficient EXECUTE command. For me, my eyes and my sole it’s less confusing and for this reason a better choice.
You can certainly use an SQL Update statement if you wish…If you use the recordset, you should test to make sure that the recordset is valid before issuing rs2.edit. Also, after issuing rs2.update, you should check to see if you have a database error before issuing a commit…
Dim sql as String
Dim ps as PostgreSQLPreparedStatement
sql = UPDATE KATbatch SET intTotalScore=$1 WHERE intID=$2
ps = PostgreSQLPreparedStatement(dbDatabase.Prepare(sql))
ps.Bind(0, intTotalScore)
ps.Bind(1, intLastID)
ps.SQLExecute
Can’t emphasize this enough from recent experience. Also, with the prepared statements, you don’t have to go all crazy with escaping out the apostrophes, quotes, etc. (all them little buggars that screw up an UPDATE transaction)
Exactly. I tend to use PPS even if I’m the only one controlling the input data
And using Postgres you don’t even have to define the BindType! That’s sweet!
[quote=120991:@Tim Hare]You must read it before you can update it.
select intID, intTotalScore from …[/quote]
[code] ’ ## UPDATE BATCH :: SCORE + EST. TIME
DIM sql as String
sql = "SELECT intID, intTotalScore FROM [KATbatch] WHERE intID = " + str(intLastID) + “;”
dim rs2 as RecordSet = dbDatabase.SQLSelect(sql)