472,328 Members | 996 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

problems due to insertion of data

1
I am using:
OS: window xp
server: IIS
Database:MS ACCESS
Browser: Internet Explorer

Please tell me what is wrong with this code:

<%
if request.form("addnow") <> "" then
dim conn, name, id, dob, dept, sql,rs
id = request.form("txtid")
name = request.form("txtname")
dob = request.form("txtdob")
dept = request.form("txtdept")

set conn = Server.createObject("ADODB.Connection")
conn.provider = "Microsoft.Jet.OLEDB.4.0"
conn.open "C:\Inetpub\wwwroot\ado\employeedatabase.mdb"


sql = "INSERT INTO Employee(id,name,dob,deptname)" & "VALUES("&id&",'"&name&"',#"&dob&"#,'"&dept&"' )"

on error resume next

conn.execute sql
if err.number<>0 then
if err.number = -2147217913 then
errormessage = "Date is wrong syntax, must be MM/DD/YYYY format:"
elseif err.number = -2147467259 then
errormessage = "Primary key already exist"
elseif err.number = -2147217904 then
errormessage = "Id must be a number!"
else
errormessage = "Unknown error ["& err.number &"] "& err.Description
end if
end if

conn.close
set conn = nothing

if errormessage = "" then
response.redirect "listing.asp"
response.end
end if
end if
%>

it give me "Primary key already exist"

thanks

leon
Nov 10 '06 #1
1 1096
I think you are trying to post an id that already exists.

Try to give an id that does not exist in the database.
Nov 10 '06 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Raju V.K | last post by:
I am developing a PHP-mysql database. It is noted that when the browser window is refreshed the data is inserted again in the database....
55
by: drhowarddrfine | last post by:
I'm working on a web site that could use some control using js but am concerned about what problems I may have with potential users having their js...
20
by: Patrick Guio | last post by:
Dear all, I have some problem with insertion operator together with namespace. I have a header file foo.h containing declaration of classes,...
5
by: John N. | last post by:
Hi All, Here I have a linked list each containing a char and is double linked. Then I have a pointer to an item in that list which is the current...
1
by: Sam | last post by:
Hi all Is it possible to remove/disable automatic new row insertion feature in datagrid control(last row with * on the left)? I'm implementing a...
7
by: Andrea | last post by:
Hi there - I'm hoping someone can help me; I've been struggling with this for a few days! :-) I have a webpage that is comprised of many...
6
by: Julia | last post by:
I am trying to sort a linked list using insertion sort. I have seen a lot of ways to get around this problem but no time-efficient and...
28
by: Peter Michaux | last post by:
Hi, I'm playing with dynamic script insertion to make a request to the server for a JavaScript file to be automatically run when it arrives in...
5
by: phiefer3 | last post by:
I'm currently a student, but this problem isn't directly related to what I have to do on an assignment. It's just a problem I've had with some...
6
by: fpcreator2000 | last post by:
Hello everyone. I'm having problems with a page I've created that is used to insert data into a database. It uploads two files into two distinct...
0
by: tammygombez | last post by:
Hey fellow JavaFX developers, I'm currently working on a project that involves using a ComboBox in JavaFX, and I've run into a bit of an issue....
0
by: tammygombez | last post by:
Hey everyone! I've been researching gaming laptops lately, and I must say, they can get pretty expensive. However, I've come across some great...
0
better678
by: better678 | last post by:
Question: Discuss your understanding of the Java platform. Is the statement "Java is interpreted" correct? Answer: Java is an object-oriented...
0
by: teenabhardwaj | last post by:
How would one discover a valid source for learning news, comfort, and help for engineering designs? Covering through piles of books takes a lot of...
0
by: CD Tom | last post by:
This happens in runtime 2013 and 2016. When a report is run and then closed a toolbar shows up and the only way to get it to go away is to right...
0
by: CD Tom | last post by:
This only shows up in access runtime. When a user select a report from my report menu when they close the report they get a menu I've called Add-ins...
0
jalbright99669
by: jalbright99669 | last post by:
Am having a bit of a time with URL Rewrite. I need to incorporate http to https redirect with a reverse proxy. I have the URL Rewrite rules made...
0
by: Matthew3360 | last post by:
Hi there. I have been struggling to find out how to use a variable as my location in my header redirect function. Here is my code. ...
1
by: Matthew3360 | last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it...

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.