Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Would you mind explaining this...

Status
Not open for further replies.

TonyU

Technical User
Feb 14, 2001
1,317
US

Microsoft OLE DB Provider for ODBC Drivers error '80040e14'

[Microsoft][ODBC Microsoft Access Driver] Syntax error (missing operator) in query expression 'jobnumber ='.

/site/signoutjob.asp, line 6


I have on a previous page a drop-down box with jobnumbers pulling from my db1 that the user selects in order to edit\change.
My problem is that when a job number is selected and the form submitted the display form is not displaying the job nubmer selected. Here's my syntax

<%
job = session(&quot;dtsearch&quot;)
sql = &quot;SELECT * FROM jobs where jobnumber = &quot;'job'&quot;
Dim RSjob
set RSjob=server.createobject(&quot;ADODB.recordset&quot;)
RSjob.open sql, &quot;DSN=matte&quot;
%>

dtsearch if the name of my drop-down box.









Tony
:)
 
???

sql = &quot;SELECT * FROM jobs where jobnumber = '&quot; & JOB & &quot;'&quot;

???
 
hey bro, would you mind explaing what the ' & the &quot;&quot; mean, or point me where I can lean what they mean. Thanks Tony
:)
 
It has to do with the difference between variables and literals. You would have to read a general tutorial about variables and how they work.

job=&quot;455&quot;

a = &quot;job&quot;
b = job

One is a string assignment and the other is a variable assignment. In the above, the variable &quot;a&quot; has the STRING value &quot;job&quot;. The variable &quot;b&quot; has the value &quot;455&quot;

The ampersand '&' is a concatenation character.

MyName = &quot;John&quot; & &quot; &quot; & &quot;Smith&quot;

This would result in MyName having the value &quot;John Smith&quot; - including a space between the first and last name.

Or we could do it this way:

MyLastName = Smith

MyName = &quot;John&quot; & &quot; &quot; & MyLastName

That should answer your question as it is identical to the problem with your sql string.







 
in sql you can only use ' ' as quotes for example

&quot;select * from table where thisfield = 'hi'&quot;

but lets say you want to put the VALUE of a variable in place of that

&quot;select * from table where thisfield = '&quot; & variable & &quot;'&quot;

if the variable was = to &quot;hello&quot; your final string (& concatnates, in otherwords it's the same as saying thisstring + thisstring) would be

&quot;select * from table where thisfield = 'hello'&quot;

so what happened above for example is like this

string1 = &quot;select * from table where thisfield = '&quot;
string2 = session(&quot;dtsearch&quot;)
string3 = &quot;'&quot;

string4 = string1 & string2 & string3

therefore string4 will be (assuming string2 is &quot;yo whats up&quot;)

&quot;select * from table where thisfield = 'yo whats up'&quot;

in any sql queries, strings must be surrounded by ' ', except for numbers(only if the field itself is other than a char/string type). Karl Blessing aka kb244{fastHACK}
kblogo.jpg
 
Oh ic, thanks guys. I goning to search for SQL statements to really learn the logic, I understand how it works, I'm having problems writting it. Thanks again. Tony
:)
 
Now a different question if I may. I now want to print that searched job number to the screen with all the field corresponding to IT, but it's not displaying at all
here's my code to print
I'm not sure if my code should read:<%=RSjob(&quot;jobnumber&quot;)%>
or
<%=RSjob(&quot;dtsearch&quot;)%> ---> the variable
******************************************
<table border=&quot;0&quot; width=&quot;105%&quot;>
<tr>
<td width=&quot;34%&quot; align=&quot;right&quot;><b><font color=&quot;#000080&quot; size=&quot;4&quot;>Job Number:</font></b></td>
<td width=&quot;22%&quot;><%=RSjob(&quot;jobnumber&quot;)%></td>
<td width=&quot;10%&quot;> </td>
<td width=&quot;20%&quot;> </td>
<td width=&quot;20%&quot;> </td>
</tr>
<tr>
<td width=&quot;34%&quot; align=&quot;right&quot;><b><font color=&quot;#000080&quot; size=&quot;4&quot;>Client:</font></b></td>
<td width=&quot;72%&quot; colspan=&quot;4&quot;><%=RSjob(&quot;client&quot;)%></td>
</tr>
<tr>
<td width=&quot;34%&quot; align=&quot;right&quot;><b><font color=&quot;#000080&quot; size=&quot;4&quot;>Task\Description:</font></b></td>
<td width=&quot;72%&quot; colspan=&quot;4&quot;><%=RSjob(&quot;task&quot;)%></td>
</tr>
</table>

******************************************

<%
dtsearch = session(&quot;dtsearch&quot;)
sql = &quot;SELECT * FROM jobs where jobnumber = '&quot; & dtsearch & &quot;'&quot;
Dim RSjob
set RSjob=server.createobject(&quot;ADODB.recordset&quot;)
RSjob.open sql, &quot;DSN=matte&quot;
%>


Tony
:)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top