I am trying to get data from the storedprocedure passing a parameter
and the code is clean if i comment the line that retreives the data.
The only task remains is how do I get the data from the recordset
because the stored procedure was executed properly. Basically the line
where --Wscript.Echo oRS.Fields("Column").Value-- needs to be replace
with some correct code that retrieves the data and echo's it.

-----------------------------------------------------------
Const adInteger = 3
Const adVarChar = 200
Const adParamInput = 1
Const adParamReturnValue = 4
Const adCmdStoredProc = 4

Dim param
Dim sServer, sDatabase, sConnection , strVal
sServer = "."
sDatabase = "DB"
sConnection = "Provider=SQLOLEDB;Data Source=" & sServer & ";Initial
Catalog=" & sDatabase & ";Integrated Security=SSPI;"

Dim oConn, oCmd
Set oConn = CreateObject("ADODB.Connection")
Set param = CreateObject("ADODB.Parameter")
Set oCmd = CreateObject("ADODB.Command")
oConn.Open sConnection

oCmd.ActiveConnection = oConn
oCmd.CommandText = "SP"
oCmd.CommandType = adCmdStoredProc
Set param = oCmd.CreateParameter("@mail",adVarChar,adParamInput,100)
oCmd.Parameters.Append param
oCmd.Parameters.Refresh
param.Value = "S@S.COM"

Dim oRS
Set oRS = CreateObject("ADODB.Recordset")
Set oRS = oCmd.Execute

--Error on this below line

Wscript.Echo oRS.Fields("Column").Value

--Error description
--Item cannot be found in the collection corresponding to the requested
name or ordinal.
--800A0CC1
--Source ADODB.Recordset

Set oCmd = Nothing
oConn.Close
Set oConn = Nothing

-----------------------------------------------------------

Re: Retrieving data from StoredProcedure passing a parameter in VBScript by Anthony

Anthony
Fri May 12 07:26:12 CDT 2006


<sachinup@gmail.com> wrote in message
news:1147377234.491024.209480@i39g2000cwa.googlegroups.com...
> I am trying to get data from the storedprocedure passing a parameter
> and the code is clean if i comment the line that retreives the data.
> The only task remains is how do I get the data from the recordset
> because the stored procedure was executed properly. Basically the line
> where --Wscript.Echo oRS.Fields("Column").Value-- needs to be replace
> with some correct code that retrieves the data and echo's it.
>
> -----------------------------------------------------------
> Const adInteger = 3
> Const adVarChar = 200
> Const adParamInput = 1
> Const adParamReturnValue = 4
> Const adCmdStoredProc = 4
>
> Dim param
> Dim sServer, sDatabase, sConnection , strVal
> sServer = "."
> sDatabase = "DB"
> sConnection = "Provider=SQLOLEDB;Data Source=" & sServer & ";Initial
> Catalog=" & sDatabase & ";Integrated Security=SSPI;"
>
> Dim oConn, oCmd
> Set oConn = CreateObject("ADODB.Connection")
> Set param = CreateObject("ADODB.Parameter")
> Set oCmd = CreateObject("ADODB.Command")
> oConn.Open sConnection
>
> oCmd.ActiveConnection = oConn
> oCmd.CommandText = "SP"
> oCmd.CommandType = adCmdStoredProc
> Set param = oCmd.CreateParameter("@mail",adVarChar,adParamInput,100)
> oCmd.Parameters.Append param
> oCmd.Parameters.Refresh
> param.Value = "S@S.COM"
>
> Dim oRS
> Set oRS = CreateObject("ADODB.Recordset")
> Set oRS = oCmd.Execute
>
> --Error on this below line
>
> Wscript.Echo oRS.Fields("Column").Value
>
> --Error description
> --Item cannot be found in the collection corresponding to the requested
> name or ordinal.
> --800A0CC1
> --Source ADODB.Recordset
>
> Set oCmd = Nothing
> oConn.Close
> Set oConn = Nothing
>
> -----------------------------------------------------------


Change this line:-

Wscript.Echo oRS.Fields("Column").Value

to:

Wscript.Echo
oRS.Fields("Name_of_field_actually_returned_in_recordset").Value

Try:-

WScript.Echo oRS.Fields(0).Name