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 - Could not find Stored Procedure error in VB script

Reply
 
Old 12-03-2008   #1 (permalink)
axapta


 
 

Could not find Stored Procedure error in VB script

Hi Guys I have the following VBS script, I get Could not find Stored
Procedure on the Execute line below.
When I examine the strSQLQuery data it contains "select * from people where
userid = 'js36'" (with quotes). It falls over too if I run it in QA with
the quotes too. How can I get this to work?

Thanks

' on error resume next

' if it's Monday then open the phonebook. Values are S(1), M(2),T(3), W(4),
T(5), F(6), S(7).
if (weekday(Date)) = 4 then

'get the login ID for the user
set net= CreateObject("wscript.network")
myLoginID=net.username
myLoginID ="'" & myLoginID & "'"

' build a SQL query and pass the login name to it
strSQLQuery = "SELECT * FROM PEOPLE WHERE USERID = " & myLoginID
strSQLQuery = """" & strSQLQuery & """"

wscript.echo strSQLQuery

' connect to the database
Set objCN = CreateObject("ADODB.Connection")
strConnection = "Driver={SQL Native
Client};Server=SQL12;Database=phonebookproddb;Trusted_Connection=yes;"

objCN.Open strConnection

' execute the query
Set objRS=CreateObject("ADODB.Recordset")


Set objRS=objCN.Execute(strSQLQuery)


' open IE and call the phonebook at the logged-in user's page
Set ie = CreateObject("InternetExplorer.Application")
iePath = "http://intranet3/phonebook/Changes/MyDetails.asp?type=P&personid="
& objRS("Personid")
ie.Navigate iePath
Do Until counter > 1000000 or Not ie.Busy
counter = counter + 1
Loop
with ie.document.parentwindow
.moveto 0,0
.resizeto .screen.availWidth, .screen.availHeight
end with
ie.menubar = true
ie.toolbar = true
ie.visible = true
end if



My System SpecsSystem Spec
Old 12-03-2008   #2 (permalink)
Richard Mueller [MVP]


 
 

Re: Could not find Stored Procedure error in VB script

axapta wrote:
Quote:

> Hi Guys I have the following VBS script, I get Could not find Stored
> Procedure on the Execute line below.
> When I examine the strSQLQuery data it contains "select * from people
> where
> userid = 'js36'" (with quotes). It falls over too if I run it in QA with
> the quotes too. How can I get this to work?
>
> Thanks
>
> ' on error resume next
>
> ' if it's Monday then open the phonebook. Values are S(1), M(2),T(3),
> W(4),
> T(5), F(6), S(7).
> if (weekday(Date)) = 4 then
>
> 'get the login ID for the user
> set net= CreateObject("wscript.network")
> myLoginID=net.username
> myLoginID ="'" & myLoginID & "'"
>
> ' build a SQL query and pass the login name to it
> strSQLQuery = "SELECT * FROM PEOPLE WHERE USERID = " & myLoginID
> strSQLQuery = """" & strSQLQuery & """"
>
> wscript.echo strSQLQuery
>
> ' connect to the database
> Set objCN = CreateObject("ADODB.Connection")
> strConnection = "Driver={SQL Native
> Client};Server=SQL12;Database=phonebookproddb;Trusted_Connection=yes;"
>
> objCN.Open strConnection
>
> ' execute the query
> Set objRS=CreateObject("ADODB.Recordset")
>
>
> Set objRS=objCN.Execute(strSQLQuery)
>
>
> ' open IE and call the phonebook at the logged-in user's page
> Set ie = CreateObject("InternetExplorer.Application")
> iePath =
> "http://intranet3/phonebook/Changes/MyDetails.asp?type=P&personid="
> & objRS("Personid")
> ie.Navigate iePath
> Do Until counter > 1000000 or Not ie.Busy
> counter = counter + 1
> Loop
> with ie.document.parentwindow
> .moveto 0,0
> .resizeto .screen.availWidth, .screen.availHeight
> end with
> ie.menubar = true
> ie.toolbar = true
> ie.visible = true
> end if
>
>
The query should be a string, but the value should include the quotes. I
would remove the following statement:

strSQLQuery = """" & strSQLQuery & """"

I believe ADO assumed the expression in quotes was the name of a stored
procedure.

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


My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
Streamreader and BCP vs SqlConnection and a Stored Procedure PowerShell
VB script - for accessing a array returned from stored procedure VB Script
executing sql stored procedure VB Script
Calling a stored procedure from powershell PowerShell
Executing Stored Procedure from Powershell PowerShell


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