missing operator

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Stevee
    New Member
    • Sep 2007
    • 30

    missing operator

    Hi, assistance would be appreciated, I have inherited a database and a bunch of .asp scripts, I have amended the database and have managed to get to view etc on line using aspmaker, GREAT (I thought). The asp's are all used to run on a different server I am now using a PC, WIndows, XP Pro through IIS. Having not used asp before I thought I'd have a quick look and see.
    The problem I am getting is:

    Error Type:
    Microsoft JET Database Engine (0x80040E14)
    Syntax error (missing operator) in query expression 'PubID ='.
    /asp/functions.asp, line 14

    The function, The first line = 9 so line 14 = rs.Open strSQL, conn:

    Function SetCurrentPub(P ubID)
    OpenDB
    Set rs=Server.Creat eObject("ADODB. Recordset")
    strSQL = "SELECT * FROM tblPublications WHERE PubID = " & PUBID & ";"
    rs.Open strSQL, conn
    Session("strPub Title")=rs("tit le")
    Session("strPub WorkingDirector y")="C:\inetpub \wwwroot\TiHo3\ tihov32.mdb" & rs("WorkingDir" )
    'Session("strPu bWorkingDirecto ry")= strMyRoot & "Working\" & rs("WorkingDir" )
    'Session("strPu bWorkingDirecto ry")= strMyRoot & "WorkingDir \" & rs("WorkingDir" )
    Session("strPub ID")=rs("PubID" )
    Session("strPub Template")=rs(" Template")
    Session("strPub TotalPages")=rs ("TotalPages ")
    Session("strPub RectsImported") =rs("RectsImpor ted")
    CloseDB
    End Function

    Any assistance would be great, thanks.

    Stevee
  • CroCrew
    Recognized Expert Contributor
    • Jan 2008
    • 564

    #2
    Hello Stevee,

    Try this:

    From:
    [code=asp]
    strSQL = "SELECT * FROM tblPublications WHERE PubID = " & PUBID & ";"
    [/code]

    To:
    [code=asp]
    strSQL = "SELECT * FROM tblPublications WHERE PubID = '" & PUBID & "'"
    [/code]

    Hope that helps~

    Comment

    • CroCrew
      Recognized Expert Contributor
      • Jan 2008
      • 564

      #3
      Or to:
      [code=asp]
      strSQL = "SELECT * FROM tblPublications WHERE PubID = " & PUBID
      [/code]
      If the database type is an integer for the field "PubID".

      CroCrew~

      Comment

      • Stevee
        New Member
        • Sep 2007
        • 30

        #4
        Thanks, I'll try them both, will advise. :-)

        Comment

        • Stevee
          New Member
          • Sep 2007
          • 30

          #5
          Originally posted by CroCrew
          Or to:
          [code=asp]
          strSQL = "SELECT * FROM tblPublications WHERE PubID = " & PUBID
          [/code]
          If the database type is an integer for the field "PubID".

          CroCrew~
          Well I have to assume it's an integer, it's actually a database table name, it now gives an:

          Unterminated string constant
          /asp/functions.asp, line 13, column 61

          Columns throw me a little.

          Stevee.

          Comment

          • CroCrew
            Recognized Expert Contributor
            • Jan 2008
            • 564

            #6
            Hello Stevee,

            Add this to your code and paste what is being printed in your browser.

            [code=asp]
            strSQL = "SELECT * FROM tblPublications WHERE PubID = " & PUBID
            Response.Write( "[" & strSQL & "]")
            Rresponse.End
            [/code]

            That will help us/me out a bit.

            Thanks~

            Comment

            • CroCrew
              Recognized Expert Contributor
              • Jan 2008
              • 564

              #7
              And is this the whole error that you’re getting?

              Originally posted by Stevee
              :
              Unterminated string constant
              /asp/functions.asp, line 13, column 61

              Comment

              • CroCrew
                Recognized Expert Contributor
                • Jan 2008
                • 564

                #8
                Right now I have to think that your local variable “PUBID” has some type of carriage return in it and that is why you’re getting the error. But, that is just a shot in the dark. We will know more after we see what you get back after showing us what your query string looks like by using the above Response.Write code.

                CroCrew~

                Comment

                • Stevee
                  New Member
                  • Sep 2007
                  • 30

                  #9
                  Originally posted by CroCrew
                  Hello Stevee,

                  Add this to your code and paste what is being printed in your browser.

                  [code=asp]
                  strSQL = "SELECT * FROM tblPublications WHERE PubID = " & PUBID
                  Response.Write( "[" & strSQL & "]")
                  Rresponse.End
                  [/code]

                  That will help us/me out a bit.

                  Thanks~
                  Where in the code, right at the begining before everything else?

                  Comment

                  • CroCrew
                    Recognized Expert Contributor
                    • Jan 2008
                    • 564

                    #10
                    Add it before the line “rs.Open strSQL, conn”

                    Comment

                    • CroCrew
                      Recognized Expert Contributor
                      • Jan 2008
                      • 564

                      #11
                      Also after we are done debugging this do this:

                      Before your line
                      [code=asp]
                      Session("strPub Title")=rs("tit le")
                      [/code]

                      add this:
                      [code=asp]
                      If (rs.EOF) Then
                      Response.Write( "No Records returned from the database!")
                      Response.End
                      End If
                      [/code]

                      Comment

                      • Stevee
                        New Member
                        • Sep 2007
                        • 30

                        #12
                        Originally posted by CroCrew
                        Add it before the line “rs.Open strSQL, conn”
                        So like this:

                        Function SetCurrentPub(P ubID)
                        OpenDB
                        Set rs=Server.Creat eObject("ADODB. Recordset")
                        'strSQL = "SELECT * FROM tblPublications WHERE PubID = " & PUBID

                        strSQL = "SELECT * FROM tblPublications WHERE PubID = " & PUBID
                        Response.Write( "[" & strSQL & "]")
                        Rresponse.End

                        rs.Open strSQL, conn
                        Session("strPub Title")=rs("tit le")
                        Session("strPub WorkingDirector y")="C:\inetpub \wwwroot\TiHo3\ tihov32.mdb" & rs("WorkingDir" )
                        'Session("strPu bWorkingDirecto ry")= strMyRoot & "Working\" & rs("WorkingDir" )
                        'Session("strPu bWorkingDirecto ry")= strMyRoot & "WorkingDir \" & rs("WorkingDir" )
                        Session("strPub ID")=rs("PubID" )
                        Session("strPub Template")=rs(" Template")
                        Session("strPub TotalPages")=rs ("TotalPages ")
                        Session("strPub RectsImported") =rs("RectsImpor ted")
                        CloseDB
                        End Function

                        Comment

                        • Stevee
                          New Member
                          • Sep 2007
                          • 30

                          #13
                          So altogether:

                          Function SetCurrentPub(P ubID)
                          OpenDB
                          Set rs=Server.Creat eObject("ADODB. Recordset")
                          'strSQL = "SELECT * FROM tblPublications WHERE PubID = " & PUBID

                          strSQL = "SELECT * FROM tblPublications WHERE PubID = " & PUBID
                          Response.Write( "[" & strSQL & "]")
                          Rresponse.End

                          rs.Open strSQL, conn

                          If (rs.EOF) Then
                          Response.Write( "No Records returned from the database!")
                          Response.End
                          End If

                          Session("strPub Title")=rs("tit le")
                          Session("strPub WorkingDirector y")="C:\inetpub \wwwroot\TiHo3\ tihov32.mdb" & rs("WorkingDir" )
                          'Session("strPu bWorkingDirecto ry")= strMyRoot & "Working\" & rs("WorkingDir" )
                          'Session("strPu bWorkingDirecto ry")= strMyRoot & "WorkingDir \" & rs("WorkingDir" )
                          Session("strPub ID")=rs("PubID" )
                          Session("strPub Template")=rs(" Template")
                          Session("strPub TotalPages")=rs ("TotalPages ")
                          Session("strPub RectsImported") =rs("RectsImpor ted")
                          CloseDB
                          End Function

                          Comment

                          • Stevee
                            New Member
                            • Sep 2007
                            • 30

                            #14
                            Or do I have to remove the line breaks?

                            Comment

                            • CroCrew
                              Recognized Expert Contributor
                              • Jan 2008
                              • 564

                              #15
                              ok like this:

                              [code=asp]
                              Function SetCurrentPub(P ubID)
                              OpenDB
                              Set rs=Server.Creat eObject("ADODB. Recordset")
                              strSQL = "SELECT * FROM tblPublications WHERE PubID = " & PUBID
                              Response.Write( "[" & strSQL & "]")
                              Response.End

                              rs.Open strSQL, conn

                              If (rs.EOF) Then
                              Response.Write( "No Records returned from the database!")
                              Response.End
                              End If

                              Session("strPub Title")=rs("tit le")
                              Session("strPub WorkingDirector y")="C:\inetpub \wwwroot\TiHo3\ tihov32.mdb" & rs("WorkingDir" )
                              'Session("strPu bWorkingDirecto ry")= strMyRoot & "Working\" & rs("WorkingDir" )
                              'Session("strPu bWorkingDirecto ry")= strMyRoot & "WorkingDir \" & rs("WorkingDir" )
                              Session("strPub ID")=rs("PubID" )
                              Session("strPub Template")=rs(" Template")
                              Session("strPub TotalPages")=rs ("TotalPages ")
                              Session("strPub RectsImported") =rs("RectsImpor ted")
                              CloseDB
                              End Function
                              [/code]

                              Comment

                              Working...