473,468 Members | 1,358 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Duplicate PK update problem ....

Hi,

I have a page which lets me select a user from a list by checking a
check box next to the specific user and pressing a submit button. The
Check box holds the value = 'UserID'.

A new form opens with the selected users details in text boxes for
editing if required. There are the following fields:
UserID (PK in table)
Password
Confirm Password
Email

When this form is submit it runs the following code:

__________________________________________________ ____

<%
vUser = request.form("user")
vPass = request.form("pass")
cPass = request.form("Cpass")
vEmail = request.form("email")

If vPass <> cPass then
response.redirect "Customer_Edit_AccessData_Error.asp"

else

uSQL = "UPDATE OrderStatusAccess SET "
uSQL = uSQL & "UserID= '" & vUser & "'"
uSQL = uSQL & ", Password = '" & vPass & "' "
uSQL = uSQL & ", Email ='" & vEmail & "'"
uSQL = uSQL & ", CustomerID = '"& session("customer") & "';"

Set RS = adoDataConn.Execute(uSQL)

Response.Redirect "Customer_AccessData_Conf.asp"
'RS.close

end if
%>

____________________________
The problem is that I get the following error:

ADODB.Connection.1 error '80004005'

SQLState: S1000
Native Error Code: 1062
[TCX][MyODBC]Duplicate entry 'DavidH' for key 1
/SceneDouble/Orders/Tracking/Customer_AccessData_Update.asp, line 29
WHAT AM I DOING WRONG ?

THANKS

David
Jul 19 '05 #1
3 1470
If you're using the UserID as your PK, and that value is known when you're
doing your update, you should be using it in a WHERE clause. As it stands
now, you'd update ALL of your records to have the same username, password,
etc., so be glad you got an error. That is actually what is causing it is
that you're trying to give ALL your records the same PK. Try:

uSQL = "UPDATE OrderStatusAccess SET "
uSQL = uSQL & ", Password = '" & vPass & "' "
uSQL = uSQL & ", Email ='" & vEmail & "'"
uSQL = uSQL & ", CustomerID = '"& session("customer") & "'"
uSQL = uSQL & " WHERE UserID= '" & vUser & "'"

Ray at work
"David" <da***@scene-double.co.uk> wrote in message
news:c1**************************@posting.google.c om...
Hi,

I have a page which lets me select a user from a list by checking a
check box next to the specific user and pressing a submit button. The
Check box holds the value = 'UserID'.

A new form opens with the selected users details in text boxes for
editing if required. There are the following fields:
UserID (PK in table)
Password
Confirm Password
Email

When this form is submit it runs the following code:

__________________________________________________ ____

<%
vUser = request.form("user")
vPass = request.form("pass")
cPass = request.form("Cpass")
vEmail = request.form("email")

If vPass <> cPass then
response.redirect "Customer_Edit_AccessData_Error.asp"

else

uSQL = "UPDATE OrderStatusAccess SET "
uSQL = uSQL & "UserID= '" & vUser & "'"
uSQL = uSQL & ", Password = '" & vPass & "' "
uSQL = uSQL & ", Email ='" & vEmail & "'"
uSQL = uSQL & ", CustomerID = '"& session("customer") & "';"

Set RS = adoDataConn.Execute(uSQL)

Response.Redirect "Customer_AccessData_Conf.asp"
'RS.close

end if
%>

____________________________
The problem is that I get the following error:

ADODB.Connection.1 error '80004005'

SQLState: S1000
Native Error Code: 1062
[TCX][MyODBC]Duplicate entry 'DavidH' for key 1
/SceneDouble/Orders/Tracking/Customer_AccessData_Update.asp, line 29
WHAT AM I DOING WRONG ?

THANKS

David

Jul 19 '05 #2
Your Update statement doesn't have a WHERE clause, so it's trying to Update
every record.
You want a statement like.....
UPDATE OrderStatusAccess Set Password='abc', Em******@y.com',
CustomerID=123 WHERE UserID=456

You are also leaving yourself open to SQL Injection attacks. Review the
article at....

http://www.sqlsecurity.com (I think that's where it is.)

Tom B

"David" <da***@scene-double.co.uk> wrote in message
news:c1**************************@posting.google.c om...
Hi,

I have a page which lets me select a user from a list by checking a
check box next to the specific user and pressing a submit button. The
Check box holds the value = 'UserID'.

A new form opens with the selected users details in text boxes for
editing if required. There are the following fields:
UserID (PK in table)
Password
Confirm Password
Email

When this form is submit it runs the following code:

__________________________________________________ ____

<%
vUser = request.form("user")
vPass = request.form("pass")
cPass = request.form("Cpass")
vEmail = request.form("email")

If vPass <> cPass then
response.redirect "Customer_Edit_AccessData_Error.asp"

else

uSQL = "UPDATE OrderStatusAccess SET "
uSQL = uSQL & "UserID= '" & vUser & "'"
uSQL = uSQL & ", Password = '" & vPass & "' "
uSQL = uSQL & ", Email ='" & vEmail & "'"
uSQL = uSQL & ", CustomerID = '"& session("customer") & "';"

Set RS = adoDataConn.Execute(uSQL)

Response.Redirect "Customer_AccessData_Conf.asp"
'RS.close

end if
%>

____________________________
The problem is that I get the following error:

ADODB.Connection.1 error '80004005'

SQLState: S1000
Native Error Code: 1062
[TCX][MyODBC]Duplicate entry 'DavidH' for key 1
/SceneDouble/Orders/Tracking/Customer_AccessData_Update.asp, line 29
WHAT AM I DOING WRONG ?

THANKS

David

Jul 19 '05 #3

Thanks Ray,

Why did'nt I think of that !

Works great now....Thanks.
David
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 19 '05 #4

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

Similar topics

2
by: jtw | last post by:
I need to update a statistics table through out the day. I would like to insert the first data sampling of the data, then update the existing record for the rest of the day. The problem is that I...
3
by: Mohammed Mazid | last post by:
Hi, Basically I have a problem with registering to my quiz system. I had borrowed some code from an existing program but I just do not know why it doesn't work. If (txtUsername = "" Or...
1
by: aleccolvin | last post by:
ON DUPLICATE KEY UPDATE is new as of MySQL 4.1.0, but the web server that I'm using has MySQL 4.0.24 How would I implement ON DUPLICATE KEY UPDATE with an old version of MySQL? Thank you,...
2
by: Pablo | last post by:
Hello, there, I have a table tblData which has pharmacy data. The table has following fields: ClaimNum, LineNum... The ClaimNum has claim number which is 12 characters. LineNum is NULL. The...
1
by: Robert | last post by:
How can I query an existing table and update a field in each record in the table with the occurrence count of each record e.g. update field to 1 (= first record occurrence), update field to 2 for...
0
by: phillip.s.powell | last post by:
CREATE TABLE /*! IF NOT EXISTS */ blah SELECT * FROM blah1 ON DUPLICATE KEY UPDATE unique_key=unique_key UNION SELECT * FROM blah2 ON DUPLICATE KEY UPDATE unique_key=unique_key TYPE=MyISAM ...
1
by: Joseph Chase | last post by:
I am running version 4.1.13a-log on a Mac XServe. How can I receive a 'duplicate entry' error for an UPDATE? An update isn't creating an entry, so why this error message? ...
7
by: Jon Maz | last post by:
Hi, I have a MySql problem I hope someone can help me with. I'm trying to run an update on a linking table, the update is running into a Primary Key constraint violation, and in my workaround...
4
by: FangQ | last post by:
hi I am very new to mysql. I have a question about using the "on duplicate update" clause with insert command. my table "data" has two columns, field1 and field2, where field1 is the index...
0
by: =?Utf-8?B?SGF3aw==?= | last post by:
Hello, I have the need to verifiy a field in a gridview for a duplicate value against a database before the update takes place. I was thinking that the gridview1.rowupdating would be a good place...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.