Solved

question about DB tables

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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…

830 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