Question : vbscript SQL Server 2005 calling SP

I have the follwoing code from various sources:

dim sServer, sConn, oConn,oRS, myCommand, adoRec
sServer="PT102BESVM01"
sConn="provider=sqloledb;data source=" & sServer & ";initial catalog=BESMgmt"
Set oConn = CreateObject("ADODB.Connection")
oConn.Open sConn, "username", "password"
Set oRS =CreateObject("ADODB.Recordset")
sSQL="SQLQuery1.sql"
oRS.open sSQL, oconn
MsgBox sSQL

This is SQLQuery1.sql :

ALTER PROCEDURE getCol
AS
SET NOCOUNT ON
BEGIN
declare @c_val int;
SELECT @c_val = RecordHash FROM dbo.SyncExchangeState;

END
GO

exec getCol

When i run the vbscript i get an error saying the procedure could not be found..
I tried giving the entire address (C:\.....) but then it gives me a syntax error.

Please help ASAP

Answer : vbscript SQL Server 2005 calling SP

Try this
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
dim sServer, sConn, oConn,oRS, myCommand, adoRec
Const adCmdStoredProc=4
sServer="PT102BESVM01"
sConn="provider=sqloledb;data source=" & sServer & ";initial catalog=BESMgmt"
Set oConn = CreateObject("ADODB.Connection")
Set oCmd = Server.CreateObject("ADODB.Command")
oConn.Open sConn, "username", "password"
Set oCmd.ActiveConnection = oConn
Set oRS =CreateObject("ADODB.Recordset")
oCmd.CommandText="SQLQuery1"
oCmd.CommandType = adCmdStoredProc
oCmd.Execute
'oRS.open sSQL, oconn
'MsgBox sSQL
msgbox oCmd.Parameters(0)
Random Solutions  
 
programming4us programming4us