
12-25-11, 08:15
|
|
Registered User
|
|
Join Date: Dec 2011
Posts: 1
|
|
|
How to fix Violation of PRIMARY KEY
|
|
Dears
Plz any one help me
I got these errors
==========
Microsoft OLE DB Provider for SQL Server error '80040e2f'
Violation of PRIMARY KEY constraint 'PK_STB_MST'. Cannot insert
duplicate key in object 'STB_MST'.
/Mgmt_mst/shell2star_proc.asp, line 224
=============
my Code
Quote:
'================================================= ========================
' server start
'================================================= ========================
strSQL = "DELETE stb_mst "
objDBStar.execute StrSQL
'================================================= ========================
strSQL = "SELECT * FROM server"
Set objRs= Server.CreateObject("ADODB.RecordSet")
With objRs
.CursorLocation = 3
.CursorType = 0
.LockType = 1
.ActiveConnection = objDBShell
.Open StrSQL
End With
Do While Not objRs.eof
strSQL = "INSERT INTO stb_mst( " &_
" STB_ID, IP, MAC, BUILDING, AISLE, "&_
" CELL_NO, ROOM_A, STB_VERSION, STATUS, CH_GROUP, "&_
" STB_ONOFF, TV_ONOFF, PX, PY, PW, "&_
" PH, REG_DATE, ENABLE "&_
" )" & _
" VALUES( "&_
" '"&objRs(1)&"', '"&objRs(3)&"', '"&objRs(10)&"',
'"&objRs(5)&"', '"&objRs(6)&"',"&_
" '"&objRs(4)&"', N'"&objRs(20)&"', '"&objRs(7)&"',
'"&objRs(9)&"', '"&objRs(11)&"',"&_
" '"&objRs(14)&"', N'"&objRs(15)&"', '"&objRs(16)&"',
'"&objRs(17)&"', '"&objRs(18)&"',"&_
" '"&objRs(19)&"', getdate(), '"&objRs(13)&"' "&_
" )"
' humm(strSQL)
objDBStar.execute StrSQL
objRs.movenext
Loop
hum("server Table is done")
|
Regards;
|
|