Solved

question about DB tables

Posted on 2003-11-03
6
254 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

813 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

13 Experts available now in Live!

Get 1:1 Help Now