Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

The Database Forum


You are currently viewing our The Database Forum as a guest. Please register to participate.
Login



Reply
Old 08-02-2008, 01:45 AM SQL problem
Junior Talker

Posts: 4
Trades: 0


I have a web site...

sometimes the page is show me this kind of messege...



Microsoft OLE DB Provider for SQL Servererror '80040e2f'
Violation of PRIMARY KEY constraint 'PK_SessionAction'. Cannot insert duplicate key in object 'dbo.SessionAction'. infoMasterUtil.asp, line 720

how can i solve the problem..?

is the problem is in line 720 ? only ?

or i need to look in ather places ?
ehud36 is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 08-02-2008, 03:57 PM Re: SQL problem
chrishirst's Avatar
Missing! presumed drunk.

Posts: 41,517
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
the problem it reported at line 720 because that is where the insert will be.

Your data is the problem, as the query is trying to insert identical data into a primary key column.
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
A foolish consistency is the hobgoblin of little minds
Thought for today:- I SEO the only industry where all the cowboys are Indians?
chrishirst is offline
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 08-03-2008, 04:36 PM Re: SQL problem
Average Talker

Posts: 18
Name: Ross
Trades: 0
try to debug and get the primary key that you are trying to use for the insert statment.
Querey the database for that primary key, if it exists then thats your issue.

There are too many factors that could result in duplicating the primary key, specially if its not the tables auto generated ID, and when you are using a combo primary key.

one more suggestion, try to wrap a transaction around your insert statments, either in code or stored procs...
__________________

Please login or register to view this content. Registration is FREE
solutionheaven is offline
Reply With Quote
View Public Profile Visit solutionheaven's homepage!
 
Old 08-04-2008, 04:32 PM Re: SQL problem
Learning Newbie's Avatar
Defies a Status

Latest Blog Post:
Astounding Republican Paranoia
Posts: 5,662
Name: John Alexander
Trades: 0
Easiest way to deal with this is to use the With (Ignore_Dup_Key=On) option. It's also the fastest. But, you need to consider it very carefully, and decide whether this is truly what your system needs.

As others have hinted at, there's a problem with your data, and the error you see is when a constraint prevents your data from going all out corrupt. That means there's a larger flaw in the system. Or, to put it another way, line 720 is only the most immediate, last stage "cause" of what you're seeing, but the problem doesn't live there.
__________________

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE
Learning Newbie is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to SQL problem
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.13589 seconds with 12 queries