Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > VB Script

Vista - Help with SQL statement

Reply
 
Old 09-08-2008   #1 (permalink)
Cmor


 
 

Help with SQL statement

I am trying to check for the existance of a server record in our SQL
db. My sql statement returns an error of: Microsoft VBScript
compilation error: Expected end of statement.

My statement is:
strSqlQuery = "SELECT item.item_sc, item.item_n,item.item_keya FROM
assyst.dbo.item WHERE item.item_sc = ' " & strComputer " ' "

There are several more fields I want to return in addition to what's
in the current statement, but getting this to work will do for now.

I'm assuming it will return a NULL recordset if the server was not
entered.

TIA,

Seymour

My System SpecsSystem Spec
Old 09-08-2008   #2 (permalink)
krazymike


 
 

Re: Help with SQL statement

> My statement is:
Quote:

> strSqlQuery = "SELECT item.item_sc, item.item_n,item.item_keya FROM
> assyst.dbo.item WHERE item.item_sc = ' " *& strComputer " ' "
You didn't concatenate the last string segment.
"SELECT item.item_sc, item.item_n,item.item_keya FROM
assyst.dbo.item WHERE item.item_sc = ' " & strComputer & " ' "
My System SpecsSystem Spec
Old 09-08-2008   #3 (permalink)
Richard Mueller [MVP]


 
 

Re: Help with SQL statement


"krazymike" <krazymike@xxxxxx> wrote in message
news:4dbee183-b17f-48db-89c5-63e82def063d@xxxxxx
Quote:

> My statement is:
> strSqlQuery = "SELECT item.item_sc, item.item_n,item.item_keya FROM
> assyst.dbo.item WHERE item.item_sc = ' " & strComputer " ' "
You didn't concatenate the last string segment.
"SELECT item.item_sc, item.item_n,item.item_keya FROM
assyst.dbo.item WHERE item.item_sc = ' " & strComputer & " ' "
------
Also, I believe the extra spaces around the value of strComputer are a
problem. I would use:
======
strSqlQuery = "SELECT item.item_sc, item.item_n, item.item_keya " _
& "FROM assyst.dbo.item " _
& "WHERE item.item_sc = '" & strComputer & "'"
====
Otherwise you have concatenated space characters to the computer name.

--
Richard Mueller
MVP Directory Services
Hilltop Lab - http://www.rlmueller.net
--


My System SpecsSystem Spec
Old 09-08-2008   #4 (permalink)
Cmor


 
 

Re: Help with SQL statement

Thanks to you both. I figured out the concatenation and was coming
back here to post that I solved it. You guys are QUICK! Now it
appears that I need to do a JOIN as some of the fields I'm looknig for
might be in another table.

I may be back for more help <g>

Seymour

On Sep 8, 3:39*pm, "Richard Mueller [MVP]" <rlmueller-
nos...@xxxxxx> wrote:
Quote:

> "krazymike" <krazym...@xxxxxx> wrote in message
>
> news:4dbee183-b17f-48db-89c5-63e82def063d@xxxxxx
>
Quote:

> > My statement is:
> > strSqlQuery = "SELECT item.item_sc, item.item_n,item.item_keya FROM
> > assyst.dbo.item WHERE item.item_sc = ' " & strComputer " ' "
>
> You didn't concatenate the last string segment.
> "SELECT item.item_sc, item.item_n,item.item_keya FROM
> assyst.dbo.item WHERE item.item_sc = ' " *& strComputer & *" ' "
> ------
> Also, I believe the extra spaces around the value of strComputer are a
> problem. I would use:
> ======
> strSqlQuery = "SELECT item.item_sc, item.item_n, item.item_keya " _
> * * & "FROM assyst.dbo.item " _
> * * & "WHERE item.item_sc = '" *& strComputer & "'"
> ====
> Otherwise you have concatenated space characters to the computer name.
>
> --
> Richard Mueller
> MVP Directory Services
> Hilltop Lab -http://www.rlmueller.net
> --
My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
Is this statement real? I can't buy but maybe U can General Discussion
First 400 Records in SQL Statement VB Script
More than one condition with the if-Statement PowerShell
just a statement Vista General


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46