Results 1 to 4 of 4

Thread: DateTime in SQL Server 2005

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2006
    Location
    /root/usr/local/bin
    Posts
    476

    DateTime in SQL Server 2005

    hello!
    i can't save to database, CALENDERED_DATE datatype is DateTime in SQL Server
    i keep on seeing this error: "Incorrect Syntax near '#'."

    comm.CommandText = "SELECT * FROM tblData WHERE RACK_NO = '"+ cboRackNo.Text +"' AND CALENDERED_DATE = #"+ Convert.ToDateTime(dtpCalenderedDate.Text).ToShortDateString() +"# AND SHIFT = '"+ cboShift.Text +"' AND ROLL_NO = "+ txtRollNo.Text +" AND POSITION = '"+ cboPosition.Text +"'";

    even i remove the "Convert function"

    this is the debug result:
    ? comm.CommandText
    "SELECT * FROM tblData WHERE RACK_NO = 'PW947' AND CALENDERED_DATE = #6/27/2007# AND SHIFT = 'Swing' AND ROLL_NO = 1 AND POSITION = 'T'"

    in reading the result i dont see any error.
    any idea how to solve?

    tnx in advance.
    *****************
    VB6,PHP,VS 2005

  2. #2
    Lively Member
    Join Date
    Mar 2005
    Location
    Dhaka, Bangladesh
    Posts
    102

    Re: DateTime in SQL Server 2005

    In case of #Date# use 'Date' in SQL Server

    Rajib
    Please Rate every reply if it is useful to u

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2006
    Location
    /root/usr/local/bin
    Posts
    476

    Re: DateTime in SQL Server 2005

    thank you for the info.
    could you explain why it don't need #(pound sign) but in msaccess needs?
    i know they are different but they are both microsoft
    *****************
    VB6,PHP,VS 2005

  4. #4
    Fanatic Member
    Join Date
    Jan 2005
    Location
    Cebu
    Posts
    607

    Re: DateTime in SQL Server 2005

    Maybe # isn't a standard complaint to ANSI SQL definition? And microsoft is devoting MSSQL to comply with the standards but not MS Access? I could be wrong here.

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