473,382 Members | 1,369 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

missing operator

30
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(PubID)
OpenDB
Set rs=Server.CreateObject("ADODB.Recordset")
strSQL = "SELECT * FROM tblPublications WHERE PubID = " & PUBID & ";"
rs.Open strSQL, conn
Session("strPubTitle")=rs("title")
Session("strPubWorkingDirectory")="C:\inetpub\wwwr oot\TiHo3\tihov32.mdb" & rs("WorkingDir")
'Session("strPubWorkingDirectory")= strMyRoot & "Working\" & rs("WorkingDir")
'Session("strPubWorkingDirectory")= strMyRoot & "WorkingDir\" & rs("WorkingDir")
Session("strPubID")=rs("PubID")
Session("strPubTemplate")=rs("Template")
Session("strPubTotalPages")=rs("TotalPages")
Session("strPubRectsImported")=rs("RectsImported")
CloseDB
End Function

Any assistance would be great, thanks.

Stevee
Feb 15 '08 #1
27 1838
CroCrew
564 Expert 512MB
Hello Stevee,

Try this:

From:
Expand|Select|Wrap|Line Numbers
  1. strSQL = "SELECT * FROM tblPublications WHERE PubID = " & PUBID & ";"
  2.  
To:
Expand|Select|Wrap|Line Numbers
  1. strSQL = "SELECT * FROM tblPublications WHERE PubID = '" & PUBID & "'"
  2.  
Hope that helps~
Feb 15 '08 #2
CroCrew
564 Expert 512MB
Or to:
Expand|Select|Wrap|Line Numbers
  1. strSQL = "SELECT * FROM tblPublications WHERE PubID = " & PUBID 
  2.  
If the database type is an integer for the field "PubID".

CroCrew~
Feb 15 '08 #3
Stevee
30
Thanks, I'll try them both, will advise. :-)
Feb 15 '08 #4
Stevee
30
Or to:
Expand|Select|Wrap|Line Numbers
  1. strSQL = "SELECT * FROM tblPublications WHERE PubID = " & PUBID 
  2.  
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.
Feb 15 '08 #5
CroCrew
564 Expert 512MB
Hello Stevee,

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

Expand|Select|Wrap|Line Numbers
  1. strSQL = "SELECT * FROM tblPublications WHERE PubID = " & PUBID 
  2. Response.Write("[" & strSQL & "]")
  3. Rresponse.End 
  4.  
That will help us/me out a bit.

Thanks~
Feb 15 '08 #6
CroCrew
564 Expert 512MB
And is this the whole error that you’re getting?

:
Unterminated string constant
/asp/functions.asp, line 13, column 61
Feb 15 '08 #7
CroCrew
564 Expert 512MB
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~
Feb 15 '08 #8
Stevee
30
Hello Stevee,

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

Expand|Select|Wrap|Line Numbers
  1. strSQL = "SELECT * FROM tblPublications WHERE PubID = " & PUBID 
  2. Response.Write("[" & strSQL & "]")
  3. Rresponse.End 
  4.  
That will help us/me out a bit.

Thanks~
Where in the code, right at the begining before everything else?
Feb 15 '08 #9
CroCrew
564 Expert 512MB
Add it before the line “rs.Open strSQL, conn”
Feb 15 '08 #10
CroCrew
564 Expert 512MB
Also after we are done debugging this do this:

Before your line
Expand|Select|Wrap|Line Numbers
  1. Session("strPubTitle")=rs("title")
  2.  
add this:
Expand|Select|Wrap|Line Numbers
  1.     If (rs.EOF) Then
  2.         Response.Write("No Records returned from the database!")
  3.         Response.End
  4.     End If
  5.  
Feb 15 '08 #11
Stevee
30
Add it before the line “rs.Open strSQL, conn”
So like this:

Function SetCurrentPub(PubID)
OpenDB
Set rs=Server.CreateObject("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("strPubTitle")=rs("title")
Session("strPubWorkingDirectory")="C:\inetpub\wwwr oot\TiHo3\tihov32.mdb" & rs("WorkingDir")
'Session("strPubWorkingDirectory")= strMyRoot & "Working\" & rs("WorkingDir")
'Session("strPubWorkingDirectory")= strMyRoot & "WorkingDir\" & rs("WorkingDir")
Session("strPubID")=rs("PubID")
Session("strPubTemplate")=rs("Template")
Session("strPubTotalPages")=rs("TotalPages")
Session("strPubRectsImported")=rs("RectsImported")
CloseDB
End Function
Feb 15 '08 #12
Stevee
30
So altogether:

Function SetCurrentPub(PubID)
OpenDB
Set rs=Server.CreateObject("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("strPubTitle")=rs("title")
Session("strPubWorkingDirectory")="C:\inetpub\wwwr oot\TiHo3\tihov32.mdb" & rs("WorkingDir")
'Session("strPubWorkingDirectory")= strMyRoot & "Working\" & rs("WorkingDir")
'Session("strPubWorkingDirectory")= strMyRoot & "WorkingDir\" & rs("WorkingDir")
Session("strPubID")=rs("PubID")
Session("strPubTemplate")=rs("Template")
Session("strPubTotalPages")=rs("TotalPages")
Session("strPubRectsImported")=rs("RectsImported")
CloseDB
End Function
Feb 15 '08 #13
Stevee
30
Or do I have to remove the line breaks?
Feb 15 '08 #14
CroCrew
564 Expert 512MB
ok like this:

Expand|Select|Wrap|Line Numbers
  1. Function SetCurrentPub(PubID)
  2. OpenDB
  3. Set rs=Server.CreateObject("ADODB.Recordset")
  4. strSQL = "SELECT * FROM tblPublications WHERE PubID = " & PUBID 
  5. Response.Write("[" & strSQL & "]")
  6. Response.End
  7.  
  8. rs.Open strSQL, conn
  9.  
  10. If (rs.EOF) Then
  11. Response.Write("No Records returned from the database!")
  12. Response.End
  13. End If
  14.  
  15. Session("strPubTitle")=rs("title")
  16. Session("strPubWorkingDirectory")="C:\inetpub\wwwroot\TiHo3\tihov32.mdb" & rs("WorkingDir")
  17. 'Session("strPubWorkingDirectory")= strMyRoot & "Working\" & rs("WorkingDir")
  18. 'Session("strPubWorkingDirectory")= strMyRoot & "WorkingDir\" & rs("WorkingDir")
  19. Session("strPubID")=rs("PubID")
  20. Session("strPubTemplate")=rs("Template")
  21. Session("strPubTotalPages")=rs("TotalPages")
  22. Session("strPubRectsImported")=rs("RectsImported")
  23. CloseDB
  24. End Function
  25.  
Feb 15 '08 #15
CroCrew
564 Expert 512MB
After you change the code and run it let us know what you get within the “[ ]” including the brackets. Please just do a copy and paste so we can see exactly how you see it.

Thanks~
Feb 15 '08 #16
Stevee
30
I'm sorry, but what has changed?
It now doesn't get an error it goes further into it but isn't actually finding the database name (I think):

[SELECT * FROM tblPublications WHERE PubID = ]

is written on the browser window, but now the #include file - top.asp (slightly different than the header.asp) is showing.
Feb 15 '08 #17
CroCrew
564 Expert 512MB
It looks like your problem is that the value getting passed into your function has no value at all. Thus, making your SQL syntax invalid.

You need to have more error trapping on your page. Here is a little that you can start to play with.

Change your code to be this:
Expand|Select|Wrap|Line Numbers
  1. Function SetCurrentPub(PubID)
  2.     OpenDB
  3.     Set rs=Server.CreateObject("ADODB.Recordset")
  4.     strSQL = "SELECT * FROM tblPublications WHERE PubID = " & PUBID 
  5.     rs.Open strSQL, conn
  6.  
  7.     If (rs.EOF) Then
  8.         Response.Write("No records returned from the database!")
  9.         Response.End
  10.     End If
  11.  
  12.     Session("strPubTitle")=rs("title")
  13.     Session("strPubWorkingDirectory")="C:\inetpub\wwwroot\TiHo3\tihov32.mdb" & rs("WorkingDir")
  14.     'Session("strPubWorkingDirectory")= strMyRoot & "Working\" & rs("WorkingDir")
  15.     'Session("strPubWorkingDirectory")= strMyRoot & "WorkingDir\" & rs("WorkingDir")
  16.     Session("strPubID")=rs("PubID")
  17.     Session("strPubTemplate")=rs("Template")
  18.     Session("strPubTotalPages")=rs("TotalPages")
  19.     Session("strPubRectsImported")=rs("RectsImported")
  20.     CloseDB
  21. End Function
  22.  
Lines 7 through 10 is checking to see if any records have been returned from the database based on your query. If no records then print something on the screen and stop processing. You can extend this more to your needs.

Hope that helps~
Feb 15 '08 #18
Stevee
30
It looks like your problem is that the value getting passed into your function has no value at all. Thus, making your SQL syntax invalid.

You need to have more error trapping on your page. Here is a little that you can start to play with.

Change your code to be this:
Expand|Select|Wrap|Line Numbers
  1. Function SetCurrentPub(PubID)
  2.     OpenDB
  3.     Set rs=Server.CreateObject("ADODB.Recordset")
  4.     strSQL = "SELECT * FROM tblPublications WHERE PubID = " & PUBID 
  5.     rs.Open strSQL, conn
  6.  
  7.     If (rs.EOF) Then
  8.         Response.Write("No records returned from the database!")
  9.         Response.End
  10.     End If
  11.  
  12.     Session("strPubTitle")=rs("title")
  13.     Session("strPubWorkingDirectory")="C:\inetpub\wwwroot\TiHo3\tihov32.mdb" & rs("WorkingDir")
  14.     'Session("strPubWorkingDirectory")= strMyRoot & "Working\" & rs("WorkingDir")
  15.     'Session("strPubWorkingDirectory")= strMyRoot & "WorkingDir\" & rs("WorkingDir")
  16.     Session("strPubID")=rs("PubID")
  17.     Session("strPubTemplate")=rs("Template")
  18.     Session("strPubTotalPages")=rs("TotalPages")
  19.     Session("strPubRectsImported")=rs("RectsImported")
  20.     CloseDB
  21. End Function
  22.  
Lines 7 through 10 is checking to see if any records have been returned from the database based on your query. If no records then print something on the screen and stop processing. You can extend this more to your needs.

Hope that helps~

I will give it a go see what happens, and let you know. I was assured that all these asp scripts I have inherited worked as were, and was told it was merely a case of changing paths to the database, but it looks like I've recieved a bag of worms!

Thanks for all your help, hope you'll be around a while longer.

Stevee
Feb 15 '08 #19
CroCrew
564 Expert 512MB
We are all here for ya 24/7 Stevee.

Happy coding~
Feb 15 '08 #20
Stevee
30
When I take out the:

Response.Write("[" & strSQL & "]")
Response.End

you had me put in earlier then I get:

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

When I put it in I get the

Included file - top.asp and then start
[SELECT * FROM tblPublications WHERE PubID = ]

Stevee.
Feb 15 '08 #21
Stevee
30
All it's actually doing is printing the 4th line:

strSQL = "SELECT * FROM tblPublications WHERE PubID = " & PUBID

Stevee
Feb 15 '08 #22
Stevee
30
Hate being stoopid but why doesn't it work when I now take out the 2 lines you gave me earlier:

Response.Write("[" & strSQL & "]")
Response.End

Stevee.
Feb 15 '08 #23
Stevee
30
We are all here for ya 24/7 Stevee.

Happy coding~
Thanks for tonight, hope to catch you tomorrow.

Stevee
Feb 15 '08 #24
CroCrew
564 Expert 512MB
Hello Stevee,

“Response” is an object that is used to send output to the user from the server.
“Write” and “End” are both methods that are used within the object.

When we use “Response.Write” in our code is when we want to paint something on to the screen. Example is Response.Write(“Hello World”) Any string value within the brackets will get painted on the screen. In this case the two words Hello World would get painted. We also can build a string value with in the brackets like this; Response.Write(“Hello World” & “ How are you?”) this would paint Hello World How are you? on the screen. We can also build a string out of variables too like this Response.Write(MyVariable) if the value of MyVariable was MyVariable=”Coding is fun” then Coding is fun would get painted on the screen.

When we use “Response.End” in our code is when we don’t want any more code to be processed. “Response.End” will stop the processing of a script at that point.

I had you put these two lines
Expand|Select|Wrap|Line Numbers
  1. Response.Write("[" & strSQL & "]")
  2. Response.End
  3.  
in your code so I could verify that the value of “PUBID” was getting passed in to your function. How I determined this is because I had you paint/write out the value for the string “strSQL”. If the local variable “PUBID” had a value we would have seen it painted on the screen with the rest of your query.

Bottom line is somewhere on your page there is a line that is calling your function and not passing in a value for “PUBID”. Also, you should places more conditional/error trapping on your page. You will understand more on why you should probably after you’re done with your project.

Still, we are here to help you so post questions whenever you need help. Just try not to bleed multiple questions into one post. That way you will get answers faster and people tend to hate reading long threads.

Good luck and happy coding~
Feb 16 '08 #25
Stevee
30
Hello Stevee,

“Response” is an object that is used to send output to the user from the server.
“Write” and “End” are both methods that are used within the object.

When we use “Response.Write” in our code is when we want to paint something on to the screen. Example is Response.Write(“Hello World”) Any string value within the brackets will get painted on the screen. In this case the two words Hello World would get painted. We also can build a string value with in the brackets like this; Response.Write(“Hello World” & “ How are you?”) this would paint Hello World How are you? on the screen. We can also build a string out of variables too like this Response.Write(MyVariable) if the value of MyVariable was MyVariable=”Coding is fun” then Coding is fun would get painted on the screen.

When we use “Response.End” in our code is when we don’t want any more code to be processed. “Response.End” will stop the processing of a script at that point.

I had you put these two lines
Expand|Select|Wrap|Line Numbers
  1. Response.Write("[" & strSQL & "]")
  2. Response.End
  3.  
in your code so I could verify that the value of “PUBID” was getting passed in to your function. How I determined this is because I had you paint/write out the value for the string “strSQL”. If the local variable “PUBID” had a value we would have seen it painted on the screen with the rest of your query.

Bottom line is somewhere on your page there is a line that is calling your function and not passing in a value for “PUBID”. Also, you should places more conditional/error trapping on your page. You will understand more on why you should probably after you’re done with your project.

Still, we are here to help you so post questions whenever you need help. Just try not to bleed multiple questions into one post. That way you will get answers faster and people tend to hate reading long threads.

Good luck and happy coding~
Thanks for that, trying to find the function that should pass the PUBID value, I have checked the paths and they all seem fine, any ideas?

Steve.
Feb 16 '08 #26
CroCrew
564 Expert 512MB
I would do a “search” for the word “SetCurrentPub” with the text editor that you’re using. If you can’t find it start checking all of the include files too.

Now when you do find it use the Response.Write on the variable that is getting passing to see if has a value.

Welcome to the wonderful world of debugging someone else’s code.

Good luck~
Feb 16 '08 #27
Stevee
30
Thanks for that, I'll give it a go.

I'm sure I'll be back soon, hope that's ok.
Feb 17 '08 #28

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: alexz | last post by:
valuA = (request.form("toadd")) If valuA = "" then SQL = "UPDATE CourseReg SET attended='Active' WHERE ID IN("&request.form("toadd")&")" Set RS = MyConn.Execute(SQL) End If MyConn.Close Set...
29
by: shank | last post by:
1) I'm getting this error: Syntax error (missing operator) in query expression on the below statement. Can I get some advice. 2) I searched ASPFAQ and came up blank. Where can find the "rules"...
5
by: Steven T. Hatton | last post by:
If you happen to have Accelerated C++ by Koenig and Moo, and haven't gotten around to reading it, I suggest you count the pages between page 18 and page 51. I came up with zero. This is very...
1
by: JMCN | last post by:
I have an ftp program that i inherited and i tried to modify it to ftp over my file however, i receive an error message : run-time error '3075 syntax error (missing operator) in query expression...
4
by: khan | last post by:
getting, error, 3075 Syntax Error (Missing Operator) in query expression '8WHERE .=1' Dim TotalQty As Integer TotalQty = DLookup("", "", "=" & Forms!!)
7
by: Chucky | last post by:
I have been going crazy slowly all week. When I step through my code I get Run Time Error 3075, Syntax error, Missing Operator in Query Expression. I think that I have narrowed the error down to...
13
by: Fir5tSight | last post by:
Hi All, I have a simple VB code: Sub OutputLine(ByRef Level As String, ByRef InfoString As String) Const gSTDOUT As Integer = -11 Dim hStdOut, BytesWritten As Integer Dim s As String s =...
3
by: access baby | last post by:
I hava a date parameter filter query but it shows error Syntax error missing operator in query experssion can some one please help where am i going wrong in expression SELECT copyorderdtl * ...
4
by: thebarefootnation | last post by:
Hi I have the following error message "Syntax Error (missing operator) in query expression" occurring when I am trying to update combo box within a form. My code is: Dim strSQL As String
1
by: Max58kl | last post by:
Hi I am trying to extract information from a txt file using the following code: #!/usr/bin/perl $i = 0; while(<STDIN>) { m/\w+\s+(.+)\t\w+\t(\d{3})\.\d{3}\.\d{4}\t(\w+)/ employee.txt; ...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.