Can't distinguished datetime fields in MSSQL

Help
Anonymous
2013-03-25
2013-05-01
  • Anonymous - 2013-03-25

    My Delphi Version: 2009
    SQL Server: 2000 and 2008
    Open DBX driver Version: 3.2012.07.24.

    My table structure is below:

    CREATE TABLE aaaaa
    (AA int, BB datetime)
    INSERT aaaaa VALUES(1, GETDATE())
    INSERT aaaaa VALUES(2, GETDATE())
    INSERT aaaaa VALUES(3, GETDATE()+50)
    

    My code is:

    procedure TForm1.Button1Click(Sender: TObject);
    var aNow: TDateTime;
    begin
      aNow:= Now();
      SimpleDataSet1.DataSet.CommandText := ''
        +'SELECT * FROM aaaaa a WHERE a.BB >= :logintime ';
      SimpleDataSet1.DataSet.ParamByName('LoginTime').AsDateTime  := aNow+45;
      SimpleDataSet1.Open();
    end;
    procedure TForm1.FormCreate(Sender: TObject);
    begin
      MsSqlConnect(cn, 2008, '127.0.0.1', 'TEST', 'DBA', 'DBA');
    end;
    

    But, I get a error at runtime. It photo below:

    Can't distinguished datetime fields! Why?

     
  • Anonymous - 2013-03-27

    Maybe is key point.
    How to access DateTime fields as TDateTimeField
    http://forums.devart.com/viewtopic.php?t=17709

    The TSQLQuery.Params will changed SQL Server's Datetime field to ftTimeStamp data type
    So, I can used code below:

    uses SqlTimSt
    ...
    SQLQuery1.ParamByName('Time').AsSQLTimeStamp := DateTimeToSQLTimeStamp(Now);
    

    It's OK. But!

    So inconvenient!!!
    Could you help me?

     

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks