1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Microsoft OLE DB Provider for SQL Server error '80040e14' Incorrect syntax near '#'.

Discussion in 'C#' started by thanasis_gt, Feb 2, 2011.

  1. #1
    Hello my friends , Can you help with this erros ??
    I change my data base from access to sqlserver 2008 and i have this problem . something wrong with dates syntax ???

    Thank you in advance for any help !!!

    sql="Select t.hotels_id,t.roomtype_id,t.startdate,t.enddate,t. capacity,count(t.room_no) as total_room from h_room t where t.hotels_id="&request("id")&" and t.capacity="&request("capacity")&"and ((#" & request("startdate") & "# Between t.startdate And t.enddate))and ((#" & DateAdd("d",-1,request("closingdate")) & "# Between t.startdate And t.enddate)) and not exists (SELECT DISTINCT b.room_id FROM h_bookinfo a,h_room_booked b WHERE a.bookinfo_id=val(b.bookinfo_id) and hotels_id="&request("id")&" and b.room_id=t.room_id and ((manual_booking=true or status=true) or (manual_booking=true and status=true)) and ((#" & request("startdate") & "# Between checkin_date And checkout_date Or checkin_date between #" & request("startdate") & "# and #" & DateAdd("d",-1,request("closingdate")) & "#) Or (#" & DateAdd("d",-1,request("closingdate")) & "# Between checkin_date And checkout_date Or checkout_date between #" & request("startdate") & "# and #" & DateAdd("d",-1,request("closingdate")) & "#) ))group by t.hotels_id,t.roomtype_id,t.capacity,t.startdate,t .enddate "&""

    ' response.Write(sql)
    rs.open sql,conn,1,3 LINE 201 ERROR
     
    thanasis_gt, Feb 2, 2011 IP
  2. gotlivechat

    gotlivechat Member

    Messages:
    516
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    35
    #2
    Making the conversion from Access to SQL Server isn't as easy as you would hope, especially considering they're both MS products :)
    If I remember SQL SERVER doesn't use the # -- check the SQL Srv documentation to see what they correct usage is for strings.
    Then you'll need to make this change to all your SQL strings...
     
    gotlivechat, Feb 4, 2011 IP
  3. clumbiecom

    clumbiecom Peon

    Messages:
    18
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    remove character #
     
    clumbiecom, Feb 27, 2011 IP