?
Solved

question about DB tables

Posted on 2003-11-03
6
Medium Priority
?
269 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses
Course of the Month10 days, 12 hours left to enroll

764 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