Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP General > Trapping odbc error when exec'ing INSERT command

Reply
Thread Tools

Trapping odbc error when exec'ing INSERT command

 
 
Doo-Dah Man
Guest
Posts: n/a
 
      03-22-2005
I hope this is the right group for this question, if it's not please
direct me.

I have a data-driven website that allows users to enter records for
sales leads. It all works perfectly. The only thing I want to do
right now is prohibit users from entering the same lead twice. I have
a PK field in the MS Access database that, obviously, disallows
duplicate records. However, when such an attempt is made, the browser
redirects to some generic ODBC error page with some cryptic numbers
and other information that will stymie the users. "It doesn't work",
they will say. The text of that error indicates that they tried to
add a record that violates the PK rule of disallowing duplicate
records. But they probably won't read it and it's truly ugly anyway.

How can I redirect to a custom error page or trap the error before the
ODBC error page is displayed and just display a msgbox or something
telling the user they attempted to add a record that already exists?

Thank you
 
Reply With Quote
 
 
 
 
Aaron [SQL Server MVP]
Guest
Posts: n/a
 
      03-22-2005
Sql = "..."
on error resume next
Conn.execute sql,,129
If err.number <> 0 then
Response.write "<script>alert('" & err.description & "');</script>"
Else
... Continue processing
End if

Also see http://www.aspfaq.com/2509


On 3/22/05 12:37 AM, in article http://www.velocityreviews.com/forums/(E-Mail Removed),
"Doo-Dah Man" <(E-Mail Removed)> wrote:

> I hope this is the right group for this question, if it's not please
> direct me.
>
> I have a data-driven website that allows users to enter records for
> sales leads. It all works perfectly. The only thing I want to do
> right now is prohibit users from entering the same lead twice. I have
> a PK field in the MS Access database that, obviously, disallows
> duplicate records. However, when such an attempt is made, the browser
> redirects to some generic ODBC error page with some cryptic numbers
> and other information that will stymie the users. "It doesn't work",
> they will say. The text of that error indicates that they tried to
> add a record that violates the PK rule of disallowing duplicate
> records. But they probably won't read it and it's truly ugly anyway.
>
> How can I redirect to a custom error page or trap the error before the
> ODBC error page is displayed and just display a msgbox or something
> telling the user they attempted to add a record that already exists?
>
> Thank you


 
Reply With Quote
 
 
 
 
Doo-Dah Man
Guest
Posts: n/a
 
      03-22-2005
Wow! Thanks for the quick response. I will give this a try tomorrow.

And thanks also for the great link.




On Tue, 22 Mar 2005 01:02:47 -0500, "Aaron [SQL Server MVP]"
<(E-Mail Removed)> stood up, looked around, realized where he
was, and wrote:

>Sql = "..."
>on error resume next
>Conn.execute sql,,129
>If err.number <> 0 then
> Response.write "<script>alert('" & err.description & "');</script>"
>Else
> ... Continue processing
>End if
>
>Also see http://www.aspfaq.com/2509
>
>
>On 3/22/05 12:37 AM, in article (E-Mail Removed),
>"Doo-Dah Man" <(E-Mail Removed)> wrote:
>
>> I hope this is the right group for this question, if it's not please
>> direct me.
>>
>> I have a data-driven website that allows users to enter records for
>> sales leads. It all works perfectly. The only thing I want to do
>> right now is prohibit users from entering the same lead twice. I have
>> a PK field in the MS Access database that, obviously, disallows
>> duplicate records. However, when such an attempt is made, the browser
>> redirects to some generic ODBC error page with some cryptic numbers
>> and other information that will stymie the users. "It doesn't work",
>> they will say. The text of that error indicates that they tried to
>> add a record that violates the PK rule of disallowing duplicate
>> records. But they probably won't read it and it's truly ugly anyway.
>>
>> How can I redirect to a custom error page or trap the error before the
>> ODBC error page is displayed and just display a msgbox or something
>> telling the user they attempted to add a record that already exists?
>>
>> Thank you


 
Reply With Quote
 
Bob Barrows [MVP]
Guest
Posts: n/a
 
      03-22-2005
Doo-Dah Man wrote:
> I hope this is the right group for this question, if it's not please
> direct me.
>

Please do not multipost Doo-Dah.This is definitely a database-related
question so .asp.db was the perfect group in which to post it. Posting it
here as well did not increase your chances of getting an answer (most of us
subscribe to both groups). On the contrary, if somebody had taken his time
to answer it here, only to find that it was already resolved in the other
group, that person may have been annoyed enough to ignore any future posts
from you, thereby decreasing your chances of getting help in the future.

There are times when you will not be sure which group is most appropriate
(again, this was not one of them), and you will want to post a question to
both groups. In that situation, you should use the cross-posting technique,
rather than posting the same message multiple times. To crosspost, put
a semicolon-delimited* list of the newsgroups to which you wish to post in
the To: header of your post and post it once. It, and any replies to it,
will appear in all the newsgroups in your list. So, if I reply in .asp.db,
my reply will also appear here in .asp.general.

* ... or whatever delimiter is recognized by your news client

--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"


 
Reply With Quote
 
Doo-Dah Man
Guest
Posts: n/a
 
      03-22-2005
Gotcha. Thanks for letting me know.




On Tue, 22 Mar 2005 06:47:31 -0500, "Bob Barrows [MVP]"
<(E-Mail Removed)> stood up, looked around, realized where he
was, and wrote:

>Doo-Dah Man wrote:
>> I hope this is the right group for this question, if it's not please
>> direct me.
>>

>Please do not multipost Doo-Dah.This is definitely a database-related
>question so .asp.db was the perfect group in which to post it. Posting it
>here as well did not increase your chances of getting an answer (most of us
>subscribe to both groups). On the contrary, if somebody had taken his time
>to answer it here, only to find that it was already resolved in the other
>group, that person may have been annoyed enough to ignore any future posts
>from you, thereby decreasing your chances of getting help in the future.
>
>There are times when you will not be sure which group is most appropriate
>(again, this was not one of them), and you will want to post a question to
>both groups. In that situation, you should use the cross-posting technique,
>rather than posting the same message multiple times. To crosspost, put
>a semicolon-delimited* list of the newsgroups to which you wish to post in
>the To: header of your post and post it once. It, and any replies to it,
>will appear in all the newsgroups in your list. So, if I reply in .asp.db,
>my reply will also appear here in .asp.general.
>
>* ... or whatever delimiter is recognized by your news client


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: The ODBC resource DLL is a different version than the ODBC driver manager beenthere Computer Support 12 10-17-2006 07:11 PM
Re: The ODBC resource DLL is a different version than the ODBC driver manager tenkbabe@yahoo.com Computer Support 0 10-16-2006 01:11 PM
ERROR [HY000] [Microsoft][ODBC Microsoft Access Driver]General error Unable to open registry key 'Temporary (volatile) Jet DSN for process 0xffc Thread 0x228 DBC 0x437b94 Jet'. ERROR [IM006] [Microsoft][ODBC Driver Manager] Driver's SQLSetConnectAttr bazzer ASP .Net 0 03-30-2006 03:16 PM
ERROR [HY000] [Microsoft][ODBC Microsoft Access Driver]General error Unable to open registry key 'Temporary (volatile) Jet DSN for process 0x8fc Thread 0x934 DBC 0x437b94 Jet'. ERROR [IM006] [Microsoft][ODBC Driver Manager] Driver's SQLSetConnectAttr bazzer ASP .Net 1 03-24-2006 04:20 PM
ERROR [HY000] [Microsoft][ODBC Microsoft Access Driver]General error Unable to open registry key 'Temporary (volatile) Jet DSN for process 0x8fc Thread 0x934 DBC 0x437b94 Jet'. ERROR [IM006] [Microsoft][ODBC Driver Manager] Driver's SQLSetConnectAttr bazzer ASP .Net 0 03-24-2006 02:22 PM



Advertisments