Datetime comparison in where clause throw exception

Discussion of open issues, suggestions and bugs regarding ADO.NET provider for Cloud Applications
Post Reply
Tilk
Posts: 2
Joined: Mon 02 Apr 2012 17:42

Datetime comparison in where clause throw exception

Post by Tilk » Mon 02 Apr 2012 18:31

Hi!

I got an issue with datetime comparison with latest version, maybe I've done something wrong...

Here is the code :

Code: Select all

SalesforceCommand command = new SalesforceCommand();
command.CommandText = "SELECT id,name,email,street,city,state,postalcode,country,division,department,title,managerid,phone,mobilephone FROM User WHERE SystemModstamp > 2012-04-01T00:00:00";

SalesforceConnectionStringBuilder csb = new SalesforceConnectionStringBuilder();
            csb.Host =  Configuration.Host;
            csb.UserId = Configuration.UserName;
            csb.Password = Configuration.Password;
            csb.SecurityToken = Configuration.AccessToken;
            csb.SystemObjects = true;

            using (SalesforceConnection conn = new SalesforceConnection(csb.ToString()))
            {
                conn.Open();
                command.Connection = conn;
                SalesforceDataReader rdr = command.ExecuteReader(); // Exception thrown here

...
Here is exception details:

Code: Select all

Devart.Data.Salesforce.SalesforceException was caught
  Message=You have an error in your SQL syntax at line 1, column 156: Unexpected symbol 'T00:'.
  Source=Devart.Data.Salesforce
  ErrorCode=-2147467259
  Cause=Unexpected
  Code=-1
  StackTrace:
       at Devart.Data.Internal.Parser.j.a(String[] A_0, ab A_1)
       at Antlr.Runtime.j.c(ab A_0)
       at a.cv()
       at a.a()
       at Devart.Data.Internal.Parser.j.c(Boolean A_0)
       at Devart.Data.Salesforce.SalesforceCommand.GetStatement()
       at Devart.Data.Salesforce.SalesforceCommand.InternalPrepare(Boolean implicitPrepare, Int32 startRecord, Int32 maxRecords)
       at Devart.Common.DbCommandBase.ExecuteDbDataReader(CommandBehavior behavior, Boolean nonQuery)
       at Devart.Common.DbCommandBase.ExecuteDbDataReader(CommandBehavior behavior)
       at System.Data.Common.DbCommand.ExecuteReader(CommandBehavior behavior)
       at Devart.Data.Salesforce.SalesforceCommand.ExecuteReader()
Here is TargetSite Module Assembly:

Code: Select all

{Devart.Data.Salesforce, Version=1.1.85.0, Culture=neutral, PublicKeyToken=09af7300eec23701}
Thanks for your help !

P.S.: Here is a link I found on SalesForce developer API documentation : http://www.salesforce.com/us/developer/ ... ormats.htm

Shalex
Site Admin
Posts: 9543
Joined: Thu 14 Aug 2008 12:44

Post by Shalex » Wed 04 Apr 2012 11:25

Please use '2012-04-01T00:00:00' (with quotation) instead of 2012-04-01T00:00:00 in your query. This is a requirement of SQL-92.

Tilk
Posts: 2
Joined: Mon 02 Apr 2012 17:42

Post by Tilk » Wed 04 Apr 2012 13:22

It didn't work before with quotation but it was previous release of dotConnect, so I forgot to try with lastest release.

So, now It works with quotation !

Thank you very much !

Post Reply