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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Quick SQL query

Status
Not open for further replies.

TJunior

IS-IT--Management
Jan 18, 2002
33
DE
Just a little stuck with an SQL query. I am trying to pull out all rows with a particular number, but can't seem to get the query working. This is what I am doing:

strQ = "SELECT JobDesc, RepDate, JobStatus "
strQ = strQ & "FROM tbl_Contracts, tbl_Jobs, tbl_Despatch, tble_Customers "
strQ = strQ & "WHERE tble_Customers.recid = '" & request.cookies("passes2") & "' "
strQ = strQ & "AND tbl_Contracts.CustomerId = tble_Customers.recid "
strQ = strQ & "AND tbl_Contracts.recid = tbl_Jobs.ContractId "
strQ = strQ & "AND tbl_Despatch.JobId = tbl_Jobs.recid "
strQ = strQ & &quot;AND tbl_Jobs.JobStatus = &quot;2&quot; &quot; <<<This is the line>>>

I thought this should work, but I am obviously doing somthing wrong. Can somebody shed some light on this for me please. Thank You.
 
is the jobstatus field a text or numeric field?

if its a numeric field then you don't need the &quot; around the value !

so the line should read:

strQ = strQ & &quot;AND tbl_Jobs.JobStatus = 2&quot;
 
yea, but looks like you're throwing a syntax error on that line.... since vbScript is trying to read that as the end of your statement.

replace the single doubles there (&quot;) with double doubles (&quot;&quot;), and see if that clears it up.

Actually, when I do this, I try to use single ticks ('), since they go right into the statement with no special gyrations needed.

:)
paul
penny1.gif
penny1.gif
 
I think you misplaced an quote
<code>
strQ = strQ & &quot;AND tbl_Jobs.JobStatus = '2'&quot;
</code>
I thinhk that's it ________
George, M
 
Thanks for that guys, it seems to have made things slightly better in that it is working for several of the numbers I want to extract. However, it doesn't seem to work for 0 (zero). Why is this? I took the double apostrophe (') route.

Whats going on here?
 
When I am using a 0 (zero) I get the error:

Error Type:
Microsoft VBScript runtime (0x800A000D)
Type mismatch: 'HTMLEncode'


Don't know why this won't work for 0 but works for the other numbers I use. Can you shed any light on this please?
 
Did you get the number from other page(submit, or querrystring)? ________
George, M
 
No the number is being retrieved straight from the database. As I said it seems to work for the other numbers in the column, but isn't working for 0.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top