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
27 1838
Hello Stevee,
Try this:
From: -
strSQL = "SELECT * FROM tblPublications WHERE PubID = " & PUBID & ";"
-
To: -
strSQL = "SELECT * FROM tblPublications WHERE PubID = '" & PUBID & "'"
-
Hope that helps~
Or to: -
strSQL = "SELECT * FROM tblPublications WHERE PubID = " & PUBID
-
If the database type is an integer for the field "PubID".
CroCrew~
Thanks, I'll try them both, will advise. :-)
Or to: -
strSQL = "SELECT * FROM tblPublications WHERE PubID = " & PUBID
-
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.
Hello Stevee,
Add this to your code and paste what is being printed in your browser. -
strSQL = "SELECT * FROM tblPublications WHERE PubID = " & PUBID
-
Response.Write("[" & strSQL & "]")
-
Rresponse.End
-
That will help us/me out a bit.
Thanks~
And is this the whole error that you’re getting?
:
Unterminated string constant
/asp/functions.asp, line 13, column 61
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~
Hello Stevee,
Add this to your code and paste what is being printed in your browser. -
strSQL = "SELECT * FROM tblPublications WHERE PubID = " & PUBID
-
Response.Write("[" & strSQL & "]")
-
Rresponse.End
-
That will help us/me out a bit.
Thanks~
Where in the code, right at the begining before everything else?
Add it before the line “rs.Open strSQL, conn”
Also after we are done debugging this do this:
Before your line -
Session("strPubTitle")=rs("title")
-
add this: -
If (rs.EOF) Then
-
Response.Write("No Records returned from the database!")
-
Response.End
-
End If
-
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
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
Or do I have to remove the line breaks?
ok like this: -
Function SetCurrentPub(PubID)
-
OpenDB
-
Set rs=Server.CreateObject("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("strPubTitle")=rs("title")
-
Session("strPubWorkingDirectory")="C:\inetpub\wwwroot\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
-
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~
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.
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: -
Function SetCurrentPub(PubID)
-
OpenDB
-
Set rs=Server.CreateObject("ADODB.Recordset")
-
strSQL = "SELECT * FROM tblPublications WHERE PubID = " & PUBID
-
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\wwwroot\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
-
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~
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: -
Function SetCurrentPub(PubID)
-
OpenDB
-
Set rs=Server.CreateObject("ADODB.Recordset")
-
strSQL = "SELECT * FROM tblPublications WHERE PubID = " & PUBID
-
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\wwwroot\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
-
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
We are all here for ya 24/7 Stevee.
Happy coding~
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.
All it's actually doing is printing the 4th line:
strSQL = "SELECT * FROM tblPublications WHERE PubID = " & PUBID
Stevee
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.
We are all here for ya 24/7 Stevee.
Happy coding~
Thanks for tonight, hope to catch you tomorrow.
Stevee
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 -
Response.Write("[" & strSQL & "]")
-
Response.End
-
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~
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 -
Response.Write("[" & strSQL & "]")
-
Response.End
-
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.
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~
Thanks for that, I'll give it a go.
I'm sure I'll be back soon, hope that's ok.
Sign in to post your reply or Sign up for a free account.
Similar topics
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...
|
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"...
|
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...
|
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...
|
by: khan |
last post by:
getting, error, 3075
Syntax Error (Missing Operator) in query expression '8WHERE
.=1'
Dim TotalQty As Integer
TotalQty = DLookup("", "", "=" &
Forms!!)
|
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...
|
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 =...
|
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 * ...
|
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
|
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;
...
|
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...
|
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...
|
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...
|
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...
|
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,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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
|
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...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
| |