Home > Back-end >  Through ADOConnetion connect to the database, a list of the query result is always wrong...
Through ADOConnetion connect to the database, a list of the query result is always wrong...

Time:02-04

Through time conditions respectively query data from two tables, and code almost

AdoCon. SQL. The clear;
AdoCon. SQL. Add (' select * from table 1 where time & gt; : time ');
AdoCon. The Parameters. ParameterByName (' time '). The Value:=Now;
AdoCon. SQL. Open;

AdoCon. SQL. The clear;
AdoCon. SQL. Add (' select * from table 2 where time & gt; : time ');
AdoCon. The Parameters. ParameterByName (' time '). The Value:=Now;
AdoCon. SQL. Open;


The first query result is correct, and the second table for more than one, is the record of time=Now, but is obviously greater than

That there is only one difference between two tables: time field is empty, table 1 and table 2 can't be empty,
Does that matter?

CodePudding user response:

Put you out of the post to see more, meet the conditions?
If meet the conditions, what's the problem? Not can only say that the results of your query conditions with wrong
If you don't meet... Countless according to the truth

CodePudding user response:

refer to the original poster Jikycc response:
the first query result is correct, and the second table for more than one, is the record of time=Now, but it is greater than


What date the cause of the accuracy of database?

CodePudding user response:

refer to the second floor simonhehe response:
refer to the original poster Jikycc response: the first query result is correct, and the second table for more than one, is the record of time=Now, but it is greater than

What date the cause of the accuracy of database?


I put the database and the conditions of my time is converted to Float type, value is the same as
But when it comes to accuracy, and that there may be
How much is the DateTime precision of Delphi? How a datetime accuracy of SQL Server 2005?

CodePudding user response:


How a datetime accuracy of SQL Server 2005?
The time precision of SQL Server 2005 3 milliseconds

CodePudding user response:

Are you sure more table 2 is that a record?
Use before and after using the best Close
AdoCon. SQL. Close;

CodePudding user response:

Actually like this kind of date/time fields, we usually use the varchar type, such good comparison, with precision, time zones, the query result is sometimes there is a problem,
If is the date/time types, it is best to have converted to char types are compared, it should be!

CodePudding user response:

Alternatively
If I can in the make an issue of time,
Time=now () data

CodePudding user response:

Now (), plus a second

CodePudding user response:

When you look at the time field, I estimate in this problem
  • Related