Re: ADO corrupts date time values in where clause



sathya wrote:
We have a propreitary application similar to VB that uses ADO for
talking to an Oracle database. We use ORaoledb.oracle as the provider.

At times we are getting error messages like "Row cannot be located for
updating" and sometimes ORA-01841 Invalid date.

This error does not happen to all the users. But once it starts
occuring for a user, it's persistent till the time user logs out and
logs back into the application.

We were able to do an oracle trace and identify the sql statements
that were causing this.

In some cases we see that the year component of a date field in the
where clause being chopped off. This happens only in fields where date
is 30-DEC-1899.
(ie) instead of passing 1899-12-30 09:30:00 it passes -12-30 09:30:00.
This throws the invalid date format error.

Also in some cases the time component seems to be offset by 10 secs
(ie) In the database if the time component of a date field is
00:00:00, ado passes 00:00:10 in the where clause. Thus causing the
unable to locate row error.

Now all these are in the where clause.Since the where clause is
something that ADO builds, we are at a loss as to what's going on.

The values for the same fields (used in the set protion of the update)
passed from the application are in correct format.



How are you passing these values? Parameters? Or concatenating dynamic sql
statements? The former is more error-proof, as well as being more secure. If
one does not use dynamic sql, one is not vulnerable to sql injection.


--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"


.