Results 1 to 3 of 3

Thread: what is wrong here ??

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Oct 1999
    Location
    Brossard, Québec, Canada
    Posts
    241

    Question

    can someone tell me what is wrong here?? (this is connected to a ms sql database throught ODBC

    Code:
        
        rstCheckupCheques.Open "SELECT * FROM Cheque " & _
                                                 "WHERE Cheque_Recipient = '" & Recipient & _
                                                 "' AND Cheque_Date = #" & CDate(GetCgiValue("Cheque_Date")) & _
                                                 "# AND Cheque_Address = '" & Address & _
                                                 "' AND Cheque_Amount = " & Amount & _
                                                 " AND Cheque_Description = '" & Description & _
                                                 "' AND Cheque_FileNo = '" & FileNo & _
                                                 "' AND Cheque_Branch = '" & ChequeBranch & "'", DBConnection, adOpenStatic
    I get the folowing error:
    [Microsoft][ODBC SQL Server Driver][SQL Server]Line 1: Incorrect syntax near '#'. Error Number = -2147217900

    I checked and GetCgiValue("Cheque_date") is not null or empty... it is a valid date

    thanks

  2. #2
    Frenzied Member
    Join Date
    Aug 2000
    Posts
    1,539

    try

    try a DATE instead of a variable
    like type 02/02/02 there and see if its a sql problem or if its the variable..


  3. #3
    Fanatic Member Stevie's Avatar
    Join Date
    Mar 2000
    Location
    London, UK
    Posts
    565
    Give this a go ...

    Code:
    rstCheckupCheques.Open "SELECT * FROM Cheque " & _
                                                 "WHERE Cheque_Recipient = '" & Recipient & _
                                                 "' AND Cheque_Date = #" & Format(CDate(GetCgiValue("Cheque_Date")), "mm/dd/yyyy") & _
                                                 "# AND Cheque_Address = '" & Address & _
                                                 "' AND Cheque_Amount = " & Amount & _
                                                 " AND Cheque_Description = '" & Description & _
                                                 "' AND Cheque_FileNo = '" & FileNo & _
                                                 "' AND Cheque_Branch = '" & ChequeBranch & "'", DBConnection, adOpenStatic
    VB6 sp5, SQL Server 2000, C#

    There are no stupid questions. Only stupid people.

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