I am developing an application which grab a comma delimited file and inserts them into a database. but while inserting it gives me an error. the code is below.
Do While Not EOF(iDrop)
Line Input #iDrop, iLine
iArray = Split(iLine, ";")
iArray(5) = Round(iArray(5) / 21.21, 0)
With rs
.AddNew
.Fields("ID") = crID
.Fields("NO") = iArray(0)
.Fields("SID") = iArray(1)
.Fields("CID") = iArray(2)
.Fields("CClass") = iArray(3)
.Fields("Cfier") = iArray(4)
.Fields("DB") = iArray(5)
.Update
End With
Loop
Close #iDate
Error:
unexpected error -2147217873 in subroutine dosomething.
[microsoft][odbc sql server driver][sql server] violation of primary key constrain PK_DBand. cannot insert duplicate key in object DB
here Dband is my table with primary key ID and DB is one of my column in the table Dband.
i am not sure why i am getting this error. It works for some records until i get this message.
in all i have about 1000 records and it does only 70-80 records and gives me this error.
any clues why this is happening. i am not sure the explaination helps or not please ask me question to understand more.
thanks