Quote:
Originally Posted by Panman
If an SQL query error occurs, is there way to detect what type of error it was? Here are the two basic things I need to detect.
1. A SELECT, UPDATE, DELETE querys:
a) It worked, all went well
b) Could not find record
c) Something else...
2. A INSERT query:
a) It worked, all went well
b) Duplicate record (ID) found, could not insert
c) Something else...
I'm sure there is a specific code to find this out but it would probably differ between database types. So, I'm just either looking for a way to have vB tell me or if someone has a nice compiled list of error codes for the supported databases. Thanks
To add to the INSERT duplicate error, I'd also need to know if it was a non-unique field/record. I have ID and NAME which both need to be unique.
|
Well since you are running vb there is only one database type, and that is mysql, the error codes for which reside over in the mysql documentation.
You cannot get a duplicate error on a field that is not indexed unique, cause the latter is a pre-requisite for the former. You can index what ever table it is you are taling about so that it has dual primary keys, or the indices on the two fields are unique.
Note that select, update and delete will not spit an error if a record is not found, it will simply not do anything to the database/return no rows