ADO question

ADO question

Postby wpacheco » Thu Aug 31, 2006 9:12 pm

Hi guys

Usually in PHP when I need to insert a record in an SQL table I check first the primary key value to avoid to get an error for duplicate key entry.
I'm uploading a .dbf file to a SQL table. The .dbf has values there exist in the SQL table. I'm using the AddNew() and Update() Method but on having tried to insert a duplicate value into the SQL table I get an error of course.
How can I check the value before the insert sentence?
This is my code
Code: Select all  Expand view  RUN
do while !cSource->( Eof() )
// cSQLCommand  := "SELECT * FROM FPPtoNom WHERE PtoNomCod=" + bTrans( AllTrim( cSource->PtoNomCod ) )
// if oCursor:Open( cSQLCommand, oSQL:oConexion:oConnection ) .and. oCursor:oRs:RecordCount = 0
   oCursor:oRs:AddNew()
   oCursor:oRs:fields("PtoNomCod"):value := AllTrim( cSource->PtoNomCod )
   oCursor:oRs:fields("PtoNomAbr"):value := AllTrim( cSource->PtoNomAbr )
   oCursor:oRs:fields("PtoNomDes"):value := AllTrim( cSource->PtoNomDes )
   oCursor:oRs:fields("PtoNomtip"):value := AllTrim( cSource->PtoNomTip )
   oCursor:oRs:Update()
// endif
   cSource->( dBSkip() )
enddo



Thanks
User avatar
wpacheco
 
Posts: 28
Joined: Tue Nov 15, 2005 1:03 am
Location: Isla Margarita, Venezuela

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 70 guests