Board index » delphi » "Date," "Time" Paradox Query problem

"Date," "Time" Paradox Query problem

w/BDE 5.01 + D3.02 Pro:

A query 'Select "Date","Time" From Table1' returns the
strings 'Date' and 'Time' in the DBGrid.

The data is stored in a Paradox 5 table w/Date field
type as 'D,' and 'Time' field as type 'T.'

If I simply open the table1 w/o a query the Date and Time
columns/data is OK. Database Explorer produces equally
correct response.
I have used TQuery in another app w/'Date' field identified
as "Date" and the data returns as expected. What could be
causing this problem?

Any help will be appreciated.

--
George Newton

geor...@rabbithole.world.std.com
(x the rabbit... when sending email)

 

Re:"Date," "Time" Paradox Query problem


Quote
> A query 'Select "Date","Time" From Table1' returns the
> strings 'Date' and 'Time' in the DBGrid.

Change the name of your columns to 'MyDate' and 'MyTime'. I believe both
are pre-defined SQL words. Then alter your query:
Select MyDate, MyTime from Table1;  {No Quotes around the column names}

Should fix your problem.

Re:"Date," "Time" Paradox Query problem


Try:

Select Table1."Date", Table1."Time" From Table1

Date and time are both reserved SQL words - see 'Column Names' in
Local SQL Help.

--
Robert Thompson
Montreal, QC, Canada

Re:"Date," "Time" Paradox Query problem


Ed,

Thanks for your reply.

I believe something else is a work here. I know they are
reserved words, but I have successfully used "Date" before
in a Query.

Changing the names would not be a problem, however, except
that I want my DBGrid column names to be simply 'Date,'
and 'Time.'
Is there a way to accomplish this w/the fields named 'MyDate'
and 'MyTime?'

--
George Newton

geor...@rabbithole.world.std.com
(x the rabbit... when sending email)

Re:"Date," "Time" Paradox Query problem


Quote
>George Newton wrote:

> A query 'Select "Date","Time" From Table1' returns the
> strings 'Date' and 'Time' in the DBGrid.

Try it this way:

  SELECT Table1."Date", Table1."Time"
  FROM Table1
or
  SELECT t."Date", t."Time"
  FROM Table1 t

Better to avoid reserved words (and names with spaces, too) as
fieldnames on principle.
________
Andreas
Delphi 5.01 Pro, NT4.0 Sp5
Direct replies mailto:p...@augsburg.netsurf.de

Re:"Date," "Time" Paradox Query problem


Quote

> Better to avoid reserved words ...

Yes, but how do you avoid DBGrid column titles such as 'MyDate'
instead of 'Date?'

--
George Newton

geor...@rabbithole.world.std.com
(x the rabbit... when sending email)

Re:"Date," "Time" Paradox Query problem


Quote
>George Newton wrote:

> Yes, but how do you avoid DBGrid column titles such as 'MyDate'
> instead of 'Date?'

You can set either the column's caption

  DBGrid.Columns[index].Title.Caption

or TField.DisplayLabel

  Table1.FieldByName('..').DisplayLabel
  Table1MyDate.DisplayLabel    // with persistent fields  
________
Andreas
Delphi 5.01 Pro, NT4.0 Sp5
Direct replies mailto:p...@augsburg.netsurf.de

Re:"Date," "Time" Paradox Query problem


If your queries are fixed at design time, you can do it easily.

Double-click the TQuery to bring up the fields editor.
Right-click in the fields editor, choose Add Fields...
With all the fields highlighted, click ok.

You now have persistent fields set up for the TQuery, and you can modify
the properties of them in the Object Inspector.  One of these properties
is DisplayLabel.  This property propagates to Data-aware controls that use
the field unless overridden in those controls.

You can do something similar at the TDbGrid level by setting up entries in
its Columns property, and setting their Title.Caption properties.

--Bill Sparrow--
Member of the UK Borland User Group

Re:"Date," "Time" Paradox Query problem


select "table1.db"."date", "table1.db"."time" from table1

--
Bill Todd (TeamB)
(Questions received via email cannot be answered.)

Other Threads