Re: TZF - Many Thanks but more help needed
Marie Vihonsky <[email protected]>
| Newsgroups | gmane.comp.lang.delphi.topaz |
|---|---|
| Message-ID | <[email protected]> |
Hi Jerry,
A simple question here - Why are you 'comparing' the ID's.
If the 2nd database (300 records) got trashed and you know that the ID's
should 'match' bewteen the 2 databases, why not just 'regenerate' the
ID's in the 2nd database using the ID from the first database?
My thought would be to:
1 - have the first database indexed on 'name'
2 - have the second database NOT indexed
3 - flip thru the second database, build the 'key' that should match the
name in the first database, do a FIND, if found, then update ID2. If NOT
FOUND, then show your messages and decide what to do.
I don't have time tonight to locate some code which will do the above,
so if you still need it - let me know and I'll look tomorrow.
Marie
Jerry Mallett wrote:
> Thank you for your response.
>
> Code as requested.
>
> procedure TForm1.Compare1Click(Sender: TObject);
> var fn,ln : string; // FirstName -
> LastName Varaibles
> id1, id2, x,y : Integer; // id1 = db1 member
> and id2 = db2 member (x & y for RecNo and RecCount)
> MatchFound : Boolean; // wanted to use this to
> exit loop when a match is found
> begin
> TzDbf.Active := True;
> TzDbf.GoTop;
> X := 1; // Initialised this
> for the ShowMessage window to see what was happening
> id2 := 0; // Initialised this
> for the ShowMessage window to see what was happening
> While NOT TzDBF.dEOF Do
> Begin
> MatchFound := False;
> fn := Trim(TzDBF.GetCField('firstname')); // get
> firstname
> ln := Trim(TzDBF.GetCField('lastname')); // get
> lastname
> id1 := TzDBF.GetLongField('memberid'); // get current
> id number
>
> // Show it on screen to see if all is ok
>
> ShowMessage('Competitor - '+fn+' '+ln+
> ' is currently '+IntToStr(id1)+
> ' but should be '+IntToStr(id2));
>
> CompetitorsFrm.Competitors.Active := True;
> CompetitorsFrm.Competitors.GoTop;
> y := CompetitorsFrm.Competitors.RecCount; // get the total
> number of records in main database (db1)
> For x := 1 to y Do
> Begin
> If (fn =
> Trim(CompetitorsFrm.Competitors.GetCField('firstname'))) AND
> (ln =
> Trim(CompetitorsFrm.Competitors.GetCField('lastname'))) Then
>
> Begin // we found a match so enter and
> update/correct the db2 file
> MatchFound := True;
> id2 :=
> CompetitorsFrm.Competitors.GetLongField('memberid'); // get the
> membership number from current record
>
> // lets display it on screen to check we have got this far
>
> ShowMessage( ' Record No.'+IntToStr(x)+
> ' = Competitor - '+fn+' '+ln+
> ' is currently '+IntToStr(id1)+
> ' but should be '+IntToStr(id2));
>
> TzDbf.SetLongField('memberid',id2); // write it to db2
> TzDbf.Post; // post it
> to db2
> End
> Else
> // ok got lost here.....tried to do x := y which
> is total recordcount so that i could exit loop but it won't compile
>
> If MatchFound Then // then tried the boolean op. but
> ....help.
> CompetitorsFrm.Competitors.Go(x);
>
> End; // For x loop
> TzDBF.Skip(1); // skip to next record
> End;
> End;
>
>
>
> R & WL Hamilton wrote:
>
>>Can you give a code sample where it crashed? Is is a crash with an error
>>or an infinite loop of searching?
>>
>>How are you comparing db2 to the correct db1 number if your db2 member
>>number is missing or wrong?
>>Roger
>>----- Original Message -----
>>From: "Jerry Mallett" <[email protected]>
>>To: <[email protected]>
>>Sent: February 9, 2003 7:30 PM
>>Subject: TZF - Many Thanks but more help needed
>>
>>
>>
>>>Hi Guys.
>>>
>>>Many thanks to all those that responded to my last problem.
>>>
>>>Got another one now which I have just spent 6 hours on without success.
>>>
>>>I'm self taught and still learning so go easy on me here.
>>>
>>>Two databases, First One containing all the proper and correct info on
>>>everyone in the club. About 1000 names addresses etc, plus a membership
>>>number.
>>>
>>>Second one containing some 300 of the same names and membership numbers
>>>but with different data.
>>>
>>>My problem is the membership nos have gone belly up in the second
>>>database and I tried to write a routine to compare db2 with db1, check
>>>the membership number from db2 with the original in db1, if they didn't
>>>match update db2 with the proper membership number from db1.
>>>
>>>Used a WHILE loop to get info from each record in turn from db2 and
>>>nested a for next loop within the while loop which went through each
>>>record in turn of db1 to do a comparison. It only partly worked then
>>>crashed.
>>>
>>>Glad I don't do this for a living. I'd be an extremely poor man today.
>>>lol
>>>
>>>Needless to say I haven't succeeded and was wondering if anyone can
>>>help...please.....
>>>
>>>
>>>Jerry
==^================================================================
This email was sent to: [email protected]
EASY UNSUBSCRIBE click here: http://topica.com/u/?clvXPN.a5kvff.Z2NsZHQt
Or send an email to: [email protected]
TOPICA - Start your own email discussion group. FREE!
http://www.topica.com/partner/tag02/create/index2.html
==^================================================================