dim sql as string
sql = "Update Boxes set Message = 'Hello World' Where blah blah blah)
I know the second code is not complete - I am just trying to ensure I have understood the concept
I am presuming they both perform the same function, just a different way of doing it?
i used both way… if you have lots of field to update, the first method is much better. if you only need to just update one field, use the second method.
dim sql as string
sql = "Update Boxes set Message = 'Hello World' Where blah blah blah)
I know the second code is not complete - I am just trying to ensure I have understood the concept
I am presuming they both perform the same function, just a different way of doing it?
Thank you all in advance.[/quote]
More or less equivalent
BUT the second one really would be more like
sql = "Update Boxes set Message = 'Hello World' Where primaryKeyForTable = <value>
If you need to update lots of fields in one record then its more or less a wash as to which one you might use
If you need to update a LOT of records all at once use some variation of the second one as you can specify a “where clause” that can match based on whatever criteria you can dream up which can be harder to do with the first form
In the second case though I would use a PREPARED STATEMENT since you DONT have to try & get all the quotes & escaping right
If I am just going to slam in a new value for a field or two, I use the Update form. I tend to use the rs.Edit route if I need to read the database record anyway.
But both of those methods still leave itself wide open for mistakes. In each case it’s very easy to fat finger a table and/or field name and you won’t know it until you go to use it at runtime. It’s one of the reasons why we use ActiveRecord - at least the compiler can tell us if we’ve made a mistake or try to assign an inappropriate datatype.