473,322 Members | 1,644 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

Trapping odbc error when exec'ing INSERT command

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
Jul 22 '05 #1
4 2186
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 js********************************@4ax.com,
"Doo-Dah Man" <ye**@right.com> 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


Jul 22 '05 #2
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]"
<te*****@dnartreb.noraa> 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 js********************************@4ax.com,
"Doo-Dah Man" <ye**@right.com> 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


Jul 22 '05 #3
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"
Jul 22 '05 #4
Gotcha. Thanks for letting me know.


On Tue, 22 Mar 2005 06:47:31 -0500, "Bob Barrows [MVP]"
<re******@NOyahoo.SPAMcom> 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


Jul 22 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: | last post by:
Hi everybody, I'm sure there's a way to do this, but I can't find it. How can I execute another .py file from my first .py file without using an exec* command? They're both in the same...
45
by: It's me | last post by:
I am new to the Python language. How do I do something like this: I know that a = 3 y = "a" print eval(y)
1
by: Raghul | last post by:
I am getting this error while copying n number of messages to the folder using imaplib.What to do to copy n number of folders in mail The error i got is imaplib.error: command COPY illegal in...
0
by: crypto_solid via AccessMonster.com | last post by:
I have been using a SQL database with a VB5 frontend for about 5 years. Works well. Unfortunately I don't have access to the source code. I was tasked with implementing a "job entry" application...
6
by: Dino Vliet | last post by:
Hi there, I want to put a number of records (variable number depending on a attribute of a table) into a certain table with a trigger statement. I have created the follwing trigger: CREATE...
0
by: howardr101 | last post by:
Hi, Have hunted around on the groups and can't find anything, hence. I've tried this against 2 mail servers (mailtraq and hmailserver) and it occus with both. The problems seems to be that...
3
by: tyngtyng | last post by:
hi... i'm new to the php and now i'm getting an error to insert my data inside the form..and also undefined index in latest_updated...... Now,i'm having trouble catching what i'm doing...
1
by: technocraze | last post by:
Hi guys, I am having trouble resolving this error. Below mentioned is my code and implmentation. MS Acess is my front end and sql server is my backend. What i want to achieve is to be...
2
by: Greg Corradini | last post by:
Hello, I've never gotten this traceback error before using mx.ODBC. Any ideas about resolving this issue? The statement and the error it generates are listed below. curse.execute("Insert into...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.