|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Stop making mediocre tutorials.The best tutorials are video! Camtasia Studio makes it easy to create engaging, buzz-building screen videos at any size, in any popular format. Download the free trial!
|
|
#1
|
|||
|
|||
|
Confirmation of INSERT in ASP/MySQL
I wrote an ASP prgram to insert a row into a MySQL database using data from a form. It works just fine, however is there a way to check a return code and trap any error that may occur (duplicate row error for example) so I can format and display a message in the browser instead of having the error just show up?
I've been looking in my ASP & MySQL books and searching on the web but can't find anything that sounds like what I want to do. Thanks for any help. Marilyn P.S. I'm going away for a few days, so if I don't answer right away, don't think I'm not interested in any answers you may post! |
|
#2
|
|||
|
|||
|
One thing you might want to look into is writing, at the top of your page,
On Error Resume Next then write you code Then write something like: If Err.Number <> 0 Then ...Trap the error here... End If Hope this helps! Sincerely Vlince NOTE: On Error Resume Next can be tricky so be careful while using it! |
|
#3
|
|||
|
|||
|
Thanks Vlince - that worked!!
Marilyn |
|
#4
|
|||
|
|||
|
you might also try a select statement on the key fields from the table to which you want to insert. if the rs comes back bof/eof, you know that you can safely insert your data into the db.
|
|
#5
|
|||
|
|||
|
Zimm,
Thanks for the suggestion. That is a good way to prevent problems beforehand. It is also something I can use in other cases as well. Marilyn |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > ASP Programming > Confirmation of INSERT in ASP/MySQL |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|