Connection Provider is not working in VBScript

4

I have the following connection string:

conn = "Provider=SQLNCLI; Server=" & conn_server &"; Database="& conn_database &"; UID="& conn_uid &"; PWD="& conn_pwd

And the code to open and run SP:

set conexao = server.CreateObject("ADODB.connection")
conexao.ConnectionString = conn
conexao.Open

set cmd = Server.CreateObject("ADODB.Command")        
cmd.ActiveConnection = conexao
cmd.CommandText = "sp_login"
cmd.CommandType = adCmdStoredProc

cmd.Parameters.Append cmd.CreateParameter("@EMA_PES", adVarChar, adParamInput, 100, login)
cmd.Parameters.Append cmd.CreateParameter("@PSW_PES", adVarChar, adParamInput, 35, psw)

set Rs1 = Server.CreateObject("ADODB.RecordSet")
Rs1.CursorLocation = adUseClient
Rs1.CursorType = adOpenStatic

Rs1.Open cmd

session("id_pes") = Rs1("id")

Rs1.Close()
Set Rs1 = nothing
conexao.Close()
Set conexao = nothing

The problem occurs in the session("id_pes") = Rs1("id") command. It says the item could not be found in the corresponding collection.

I've already checked and the command runs in the database. When I change the connection string to use Driver = {SQL Native Client} it works without problems.

Could anyone help me?

    
asked by anonymous 16.06.2014 / 21:33

1 answer

2

From what I see in your code, you are running the Stored Procedure sp_login , and then run it trying to catch a Rs1("id") id. What happens is that "apparently" (For your information) your Stored Procedure is not outputting this id .

Your driver is correct, and the error you receive has no connection to the connection, but with the attempt to read a data that does not exist in the object.

I use SQL Server 2008R2 with the SQLNCLI10 driver.

Following this link :

At the bottom of the page, you have the versions of SQL Server and when choosing the database, their respective drivers.

    
05.09.2014 / 15:52