views:

21

answers:

0

So I have .sdf database file and such query:

SELECT id, name, url, lastSynchronized, synchronizationInterval, fileExtensions FROM pathconfiguration WHERE remote = 1 and (manualSynchronizationRequest = 1 OR (synchronizationInterval IS NOT NULL AND dateadd(minute, synchronizationInterval, COALESCE(lastSynchronized, '1900-01-01')) < GETDATE()))

When I am trying to execute SqlCeCommand.ExecuteReader() method it returns me an Empty Reader, but when I remove from initial query all stuff related to the dates manipulations it works correctly.

AND dateadd(minute, synchronizationInterval, COALESCE(lastSynchronized, '1900-01-01')) < GETDATE()))

Could you help me?

Update: So, I have such table:

id   name     url                lastSynchronized           synchronizationInterval fileExtensions
1    name1    http://xxx/xxx.xml 2010-09-17 15:06:35.500    1440                     *.*
2    name2    http:///xxx/xx.xml NULL                       NULL                   *.xxx

And I want to get the first row with id=1? What is wrong?

This is some code, which is trying to access .sdf database file:

    void FileUpdateInterface.SynchronizeRemoteDbs(ref bool abort)
    {
        DataTable remotePaths = this.ListRemotePathsToBeSynchronized();
        if (remotePaths != null)
        {
            foreach (DataRow dr in remotePaths.Rows) {}
        }
    }

    private DataTable ListRemotePathsToBeSynchronized()
    {
        string sql = "SELECT id, name, url, lastSynchronized, synchronizationInterval, fileExtensions FROM pathconfiguration WHERE remote = 1 and (manualSynchronizationRequest = 1 OR (synchronizationInterval IS NOT NULL AND dateadd(minute, synchronizationInterval, COALESCE(lastSynchronized, '1900-01-01')) < GETDATE()))";

        DbCommandWrapper cmd = GetCommand(sql);
        DataTable dt = cmd.ExecuteDataTable();
        return dt;
    }

    public virtual DataTable ExecuteDataTable()
    {
        DataTable ret;
        ret = DataReaderAdapter.GetDataTableAndClose(ExecuteReader(), helpers);
        return ret;
    }

    public virtual DbDataReader ExecuteReader()
    {
        DbDataReader ret;
        try
        {
            ret = cmd.ExecuteReader();
        }
        catch (System.SystemException ex)
        { }
        // dispose...
        return ret;
    }

Sometimes when I execute cmd.ExecuteReader() method it returns an empty reader.