Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Aug 19th, 2005, 3:36 PM   #1
gj15987
Programmer
 
Join Date: Feb 2005
Posts: 45
Rep Power: 0 gj15987 is on a distinguished road
Index in a table

How do I create an index to sort a table?! I have created an index using Database desktop, which is what I used to create the tables. However when I add a new record it then tells me that the index is out of date.

If you've read in my other post in the Working projects forum you'll know that I need to sort clock in/ out records so that when searching it will come to the newest first.
gj15987 is offline   Reply With Quote
Old Aug 19th, 2005, 3:52 PM   #2
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
Don't make me want to install Delphi, now .
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code.
Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers
DaWei is offline   Reply With Quote
Old Aug 19th, 2005, 4:00 PM   #3
Ooble
I eat cake for breakfast.
 
Ooble's Avatar
 
Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9 Ooble is on a distinguished road
Quote:
Originally Posted by DaWei
Don't make me want to install Delphi, now .
You don't wanna do that. It's evil. Evil, I tells ya!

GJ, are you using some weird Delphi controls to interface with the database, or are you using SQL connectors? What database are you using, anyway?
__________________
Me :: You :: Them
Ooble is offline   Reply With Quote
Old Aug 19th, 2005, 4:41 PM   #4
gj15987
Programmer
 
Join Date: Feb 2005
Posts: 45
Rep Power: 0 gj15987 is on a distinguished road
Hmmm...I'm using sql to update and add records on the clock in thingy. But to access the table data I'm placing the delphi TTable things on the page and then using things like table1.open, table1.next etc to search through them and stuff.

the databases are paradox 7...don't know why..thats just what the teacher told us to use at college.
gj15987 is offline   Reply With Quote
Old Aug 19th, 2005, 4:46 PM   #5
Ooble
I eat cake for breakfast.
 
Ooble's Avatar
 
Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9 Ooble is on a distinguished road
Damn... I cannot for the life of me remember how to work databases in Delphi...
__________________
Me :: You :: Them
Ooble is offline   Reply With Quote
Old Aug 19th, 2005, 6:16 PM   #6
gj15987
Programmer
 
Join Date: Feb 2005
Posts: 45
Rep Power: 0 gj15987 is on a distinguished road
Sokay...I have yet again recided to think of another way to clock in without sorting them and I think I've found a way that's simple and that works. I'll post it when I've tested it n stuff.
gj15987 is offline   Reply With Quote
Old Aug 19th, 2005, 7:34 PM   #7
Ooble
I eat cake for breakfast.
 
Ooble's Avatar
 
Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9 Ooble is on a distinguished road
Glad to hear it.
__________________
Me :: You :: Them
Ooble is offline   Reply With Quote
Old Aug 20th, 2005, 6:06 AM   #8
gj15987
Programmer
 
Join Date: Feb 2005
Posts: 45
Rep Power: 0 gj15987 is on a distinguished road
WOOOHOOO!!! Ok, this works! I've tried all possible cases and it works!

I took your idea into acount Ooble, and had a field called Active in the shift table. When no active shift is found for that employee it creates a record and sets the active field to true. Then when searching again it finds the true value and clocks it out! This is so much simpler than what I was trying to do before! lol

procedure Tfrm_clock_In.btn_enterClick(Sender: TObject);
var
        Executed:boolean;
        found:boolean;
begin
found:=false;
Executed:=false;
tbl_employees.Open;
tbl_employees.First;
Repeat
        If (Tbl_EmployeesEmployee_ID.value = strtoint(Edit_Employee_ID.text)) then
           begin
                found:=true;
                showmessage('found employee');
                Tbl_shift.Open;
                Tbl_shift.first;
                Repeat
                        If (Tbl_shiftEmployee_ID.value = strtoint(Edit_Employee_ID.text)) and (tbl_shiftActive.value=true) then
                                begin
                                        //Clock out
                                        Executed:=true;
                                        showmessage('Clocked Out')
                                end
                        else begin tbl_shift.next; showmessage('Shift Next'); end;
                Until (tbl_shift.Eof) or (executed=true);
           end
        else begin tbl_employees.Next; showmessage('employees next'); end;
Until (found = true) or (tbl_employees.Eof);

if tbl_employees.Eof then showmessage('Invalid Employee ID');

If tbl_shift.eof then
        begin
                //clock in
                showmessage('Clocked In');
        end;

end;
gj15987 is offline   Reply With Quote
Old Aug 20th, 2005, 6:16 AM   #9
Ooble
I eat cake for breakfast.
 
Ooble's Avatar
 
Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9 Ooble is on a distinguished road
Congrats, mate. That reminds me... I really should get on with my Year 13 coursework...
__________________
Me :: You :: Them
Ooble is offline   Reply With Quote
Old Aug 20th, 2005, 7:27 AM   #10
gj15987
Programmer
 
Join Date: Feb 2005
Posts: 45
Rep Power: 0 gj15987 is on a distinguished road
Tried and tested and it works perfectly! I had to add a shift_ID field to the shift table so that the sql didn't update every field when clocking out.

Really though...Ooble, are you like a child prodigy? When did you start programming? You're miles ahead of me and we're in the same year! lol.
gj15987 is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 7:00 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC