Solved

question about DB tables

Posted on 2003-11-03
6
247 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
  • 2
6 Comments
 
LVL 4

Accepted Solution

by:
brunomsilva earned 88 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 87 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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
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…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

759 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now