CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6
  1. #1
    Join Date
    Jul 1999
    Posts
    57

    How to judge a time-typed field in SQL statement?

    I want to use a SQL statement with condition to get records,
    the condition is date>DEC. 30,1996. But the database returns
    error, either I look on the "date" field as CHAR-typed or
    VALUE-typed. In my program, this field named "date" is CTIME-
    typed in CRECORDSET,while SQL_C_CHAR-typed in SQLALLOCHANDLE.
    Whatever I type like these,they don't work:
    sr=SQLExecDirect(stmt,
    (SQLCHAR*)"select * from stock where date='19961230'"
    ,SQL_NTS);

    sr=SQLExecDirect(stmt,
    (SQLCHAR*)"select * from stock where date>19961230"
    ,SQL_NTS);
    Can anybody help me,please?


  2. #2
    Join Date
    Jun 1999
    Posts
    47

    Re: How to judge a time-typed field in SQL statement?

    I'm not sure of this but i also got an arror like that in mySQL. Try to rename that field from date to _Date or date1 or something like that. I did so and it worked. The mySQL missunderstood the date directive, and I gues yout sql does it too.
    Hope this would help...


    Regards,
    Dani Zilcsak
    mailto[email protected]

  3. #3
    Join Date
    Apr 1999
    Posts
    27

    Re: How to judge a time-typed field in SQL statement?

    Isn't date a key (or reserved) word in most DBs? I would change the name of the field to something else and try it then.


  4. #4
    Join Date
    Jul 1999
    Posts
    57

    Re: How to judge a time-typed field in SQL statement?

    I change the field name "date" to others,like
    dd,aa or else,but the "sr" still returns SQL_ERROR.
    I really have no idea now.

    Thank you all for your reply.


  5. #5
    Join Date
    Jul 1999
    Posts
    57

    I know the reason & change it,but still wrong.

    SQLDATE[]="19961230";
    sr=SQLExecDirect(stmt,
    (SQLCHAR*)"select * from stock where dd>d",
    SQL_NTS);
    I have sent a SQLDATE variable to statement,
    unfortunately,wrong again.

    simon
    [email protected]




  6. #6
    Join Date
    Jul 1999
    Posts
    57

    I have known the right answer

    It should be "...dd>#1996/12/30#",
    now I want to use SQLBindParameter,but how to send
    this string to statement?

    Best Regards
    simon
    [email protected]


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured