![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Programmer
Join Date: Feb 2005
Posts: 45
Rep Power: 0
![]() |
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. |
|
|
|
|
|
#2 |
|
Resident Grouch
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Jun 2005
Posts: 6,453
Rep Power: 10
![]() |
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 |
|
|
|
|
|
#3 | |
|
I eat cake for breakfast.
![]() ![]() ![]() ![]() Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9
![]() |
Quote:
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? |
|
|
|
|
|
|
#4 |
|
Programmer
Join Date: Feb 2005
Posts: 45
Rep Power: 0
![]() |
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. |
|
|
|
|
|
#5 |
|
I eat cake for breakfast.
![]() ![]() ![]() ![]() Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9
![]() |
Damn... I cannot for the life of me remember how to work databases in Delphi...
|
|
|
|
|
|
#6 |
|
Programmer
Join Date: Feb 2005
Posts: 45
Rep Power: 0
![]() |
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.
|
|
|
|
|
|
#7 |
|
I eat cake for breakfast.
![]() ![]() ![]() ![]() Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9
![]() |
Glad to hear it.
|
|
|
|
|
|
#8 |
|
Programmer
Join Date: Feb 2005
Posts: 45
Rep Power: 0
![]() |
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! lolprocedure 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; |
|
|
|
|
|
#9 |
|
I eat cake for breakfast.
![]() ![]() ![]() ![]() Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9
![]() |
Congrats, mate. That reminds me... I really should get on with my Year 13 coursework...
|
|
|
|
|
|
#10 |
|
Programmer
Join Date: Feb 2005
Posts: 45
Rep Power: 0
![]() |
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. |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|