Hi,
I am going through the Your First Web App series in xDev magazine, changing the code to use API 2.0. This is the code for the UpdateRecord Method I have:
[code]Var d As DateTime = DateTime.Now
Try
Var ps As SQLitePreparedStatement = _
Session.mediaDB.Prepare(“UPDATE Media SET TITLE = ?, Type = ?, Year = ?, Notes = ?, Added = ? WHERE ID_MEDIA = ?”)
ps.BindType(0, SQLitePreparedStatement.SQLITE_TEXT)
ps.BindType(1, SQLitePreparedStatement.SQLITE_TEXT)
ps.BindType(2, SQLitePreparedStatement.SQLITE_TEXT)
ps.BindType(3, SQLitePreparedStatement.SQLITE_TEXT)
ps.BindType(4, SQLitePreparedStatement.SQLITE_TEXT)
ps.BindType(5, SQLitePreparedStatement.SQLITE_TEXT)
ps.ExecuteSQL(txtTitle.Text, popType.Text, txtYear.Text, txtNotes.Text, d.SQLDate, id)
Catch error As DatabaseException
MessageBox("Update record error: " + error.Message)
End Try
webMain.Show
Self.close[/code]
Everything looks fine, thing is the record is not updated. After pulling my hair a lot, I finally found out what’s wrong. In the prepared statement there is an error with the name of a column: I should have typed MediaType instead of Type.
Shouldn’t that throw an exception ? I may understand that at the Prepare Statement it may not get catch, but what about ExecuteSQL, since I try to get a non existent column ?
Does some one have an explanation for that ?
Thanks