Know a good article or link that we're missing? Submit it!

C++ Builder

Moderators: Lundin
Number of threads: 443
Number of posts: 1047

This Forum Only
Post New Thread

Report
Database Code Help Posted by alejitro on 15 Nov 2009 at 5:09 PM
Hi People

I'm new in database programming, i have an Access database and i'm trying to eliminate some records in a table, here is the code

Table6->First();
for(int i=0;i<Table6->RecordCount;i++){
placa=Table6->FieldByName("Placa")->AsString;
tiempo=Table6->FieldByName("Tiempo")->AsString.ToDouble();
for(int j=0;j<Table6->RecordCount;j++){
Table6->First();
Table6->MoveBy(j);
placa2=Table6->FieldByName("Placa")->AsString;
tiempo1=Table6->FieldByName("Tiempo")->AsString.ToDouble();
if(placa==placa2){
if(tiempo<tiempo1){
valor = Variant(tiempo1);
Table6->Locate("Tiempo",valor,Opts);
Table6->Delete();
Table6->Refresh();
}
if(tiempo1<=tiempo){
valor = Variant(tiempo);
Table6->Locate("Tiempo",valor,Opts);
Table6->Delete();
Table6->Refresh();
}
}
}
Table6->First();
Table6->MoveBy(i);
}

The idea is when placa=placa2 make a comparison of the field "Tiempo"
if the time of placa is less than time of placa2 the record that must be delete is placa2 else, the record must be delete it placa, i don't know what's the error here, i'll be very grateful if you can help me.

Alejandro



 
Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2010 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
bootstrapLabs Logo A BootstrapLabs project.