database - Wrong Result after Refresh pressed on DbNavigator Delphi -


I have encountered a very strange situation here. I'm reaching the database through JAT (MDB) I use the user to access DBGrid and DBNewigator to access it. Dataset is created using the TADOQuery component, with the following query:

  SELECT *, (Date '', [Date of birth], now ())) [Age]  

This works fine but whenever I press the refresh button on DBNewigator, the results of this calculated field are incorrect. For example, if I have been shown 7 on the age column in general, then after refreshing I have 40149, 40149 in 701, 6 changes 40150, 0 to 40156 etc. To see the correct results, I have to open the query again. / P>

Can anyone help you?

Try the following, which will return the age of the day.

Use for age in the year:

  SELECT *, CINT (now () - [Date of birth]) / P> 
  SELECT *, INT ([now () - [Date of birth]) / 365.242199) As the name of the table  

(Note, CITT round , Not INT)

The reason for this is that ACCESS stores its date / time in the same method as Delphi, in the form of a float, where the integer part is the number of days since a particular day and Partial part as partial A part of the day (0:25 to 6 pm, 0.50 = lunch, etc.). Thus, if you want to know the differences between the two days, then divide it with the number of days between the number of days, for the number of years, the number of days in a year.

Edit

Another option here would be to create a calculated field in Delphi and there must be logic executed. In your calculated event, you will do some code like:

  Process TForm1.ds1CalcFields (Dataset: TDataSet); Start DataSet.FieldByName ('CALCDATE'). AsInteger: = Trunc ((Date - DataSet.FieldByName ('Date of Birth'). AsDateTime) / 365.242199); End;  

edit

and yet there is a third method. Instead of allowing refresh to work currently, override the behavior and open one of the datasets on the netset using onClick:

  Process TForm1.dbnvgr1Click (From: TObject ; Button: TNavigateBtn); Then start button = nb refresh then starts ds1.Close; Ds1.Open; End; End;  

Comments

Popular posts from this blog

c# - How to capture HTTP packet with SharpPcap -

php - Multiple Select with Explode: only returns the word "Array" -

php - jQuery AJAX Post not working -