Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

question about DB tables

Posted on 2003-11-03
6
Medium Priority
?
270 Views
Last Modified: 2010-04-05
actually i got a few simple question:
1)when i append a new recored i want it show in the top of the grid, i mean that the latest record will show up in the top of the grid when i append.
2)how can i manually post new changes to the DB without using DBNavigator?
3)how can i deletle all recordes that they're DATE FIELD which is TDateTime has been expired  30 days from the current date? is there a procedure that can make it easier?
0
Comment
Question by:tomerlei
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
6 Comments
 
LVL 4

Accepted Solution

by:
brunomsilva earned 352 total points
ID: 9672741
1) you can have a field which identifies the record and then sort it by that field in a descendent way.
2) you can use something like:
table.edit;
table.field.value:= 'test';
table.post;

or for a new record

table.appendrecords([table.fields.item.['ok'].value]);

check the delphi help on those functions for more details. i'm not sure if everything is correct.

3) use a sql command like:

"DELETE FROM Table WHERE Table.Date>#12-12-2000#"

Again check this for accuracy as it depends on the DBMS you are using.

Bye,
 Bruno
0
 
LVL 4

Author Comment

by:tomerlei
ID: 9676858
1) i have 2 fields TIME and DATE the latest DATE and TIME should be at the top
instead of the bottom where they are right now, i think it will be more simple to add the records at the beginning of the table.
3) how do i use sql on my table?
0
 
LVL 27

Assisted Solution

by:kretzschmar
kretzschmar earned 348 total points
ID: 9677085
to 1.

simple use the beforeInsert-event of the Dataset like

procedure TForm1.ADOTable1BeforeInsert(DataSet: TDataSet);
begin
  Dataset.First;
end;

to 2.

as brunomsilva showed

to 3.

you need a query-object for this kind of deletion.
use the execSQL-method with the statement,
which is showed by brunomsilva

meikl ;-)
0
 
LVL 4

Author Comment

by:tomerlei
ID: 9685581
1) somewhy it wont work for me, the new records are still at the bottom of the grid.
3) the sql line you gave me wont work, can you give me something more specific?
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
Suggested Courses

618 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question