I have a code that reads AC no, RTN, name and AMT in the record file and reads the stores in stores. After this I have created SQL which stores RecordSet data in the SQL Server 2005 table.
The problem is that the exono column has the primary key but in my text file I have some duplicate exxno while adding the record set in the database, if it looks like a duplicate esenano, then it is stopping there and that duplicate The column is not inserting a row after.
Now what I want to do is if there is a duplicate column, then I want to store that column in the log file and leave that column and put the remaining column in the dash. I do not know how to do this. Can anybody help me. Check out how to duplicate columns and leave that and prefer to insert the rest. Record the database to frmDNELoad.lblStatus.Caption = "Data Loading Database in ......" dim lngRecCount as long lngRecCount cmdCommand with = 0 .ActiveConnection = objConn .CommandText = 'And the "rcdDNE" ("RTN") and "t_DATA_DneFrc (RTN, AccountNbr, First, MiddleName, Last Name, Zodiac) values (" "', '' and rcdDNE rcdDNE.MoveFirst (" AccountNbr ") and" '' And rcdDNE ("first") and "'," "and rcdDNE (" MiddleName ") and"', "" and rcdDNE ("last name") and "'," and RcdDNE ("zodiac") and "')" .CommandType = adCmdText end set rcddnefrc = New ADODB.Recordset with rcddnefrc .ActiveConnection = objConn. Source = "Select * FROM T_DATA_DNEFRC" .CursorType = adO PenDynamic .CursorLocation = adUseClient .LockType = AdLockOptimistic.Until rcdDNE.EOF lngRecCount = lngRecCount + 1 frmDNELoad.lblStatus.Caption = "Adding a record" & lngRecCount & "of" & rcdDNE.RecordCount and "in database." FrmDNELoad.Refresh DoEvents Call CommitNew rcdDNE.MoveNext Loop frmDNELoad.lblStatus.Caption = "DNE Processing Complete." FrmDNELoad.Refresh termination function Sub CommitNew () 'rcddnefrc .Requery. AddNew. Add records on DneFrc table with fields! [RTN] = rcdDNE.Fields! [RTN] .Fields! [AccountNbr] = rcdDNE.Fields! [AccountNBR]. Fields! [First] = rcdDNE.Fields! [First] .Fields! [MiddleName] = rcdDNE.Fields! [MiddleName] .Fields! [Last name] = rcdDNE.Fields! [LASTNAME] .Fields! [Zodiac] = rcdDNE Fields! [Zodiac] .Update with End End Sub
to add to the maintenance of my suggestion error Will be commissions new
to see if the row will insert the primary key infringed, and if it is, then handling the other.
example:
sub-comment new) '' error on gotit Niv_Error DaveFrc #Add record on table rcddnefrc .Requery .addNew with Fields! [RTN] = rcdDNE.Fields! [RTN] .Fields! [AccountNbr] = rcdDNE.Fields! [AccountNbr] .Fields! [First] = rcdDNE.Fields! [First] .Fields! [MiddleName] = rcdDNE.Fields! [MiddleName] .Fields! [Last name] = rcdDNE.Fields! [LASTNAME] .Fields! [Zodiac] = rcdDNE. Feilds! [Zodiac] .Update with subdue sub end '# # If there is no error, then run out routine. CommitNew_Error: If Err.Number = -2147217873 then 'Since you handled' # here the code will only execute if the barrier is infringed call WriteDuplicateAccountToFile () Err.Clear () '' #This clears the error, else '' # Do not do other things with errors "# # If you are not sure, at least show what error its giving, so much MsgBox" had encountered the following error, when the new record was saved: "& amp; ; _VbNewLine & amp; CSRT (error number) & amp; "-" & amp; Error. Description & amp; VbNewLine & amp; _ "New record not saved.", VbOkOnly + vbCritical, "Error" end then End Sub
No comments:
Post a Comment