Discussion Locked

Use Cursor Data Type of SQLServer in VB

0 helpful
2 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

Dear Friends,

I am using Visual Basic 6,ADO 2.6,SQL Server 2000. When i execute a stored procedure from vb, which returns Cursor Data Type.

sample:-
Dim conGetUserNames As New ADODB.Connection
Dim cmdGetUserNames As New ADODB.Command
Dim rsGetUserNames As New ADODB.Recordset

rsGetUserNames.CursorLocation = adUseClient
rsGetUserNames.CursorType = adOpenKeyset

Set conGetUserNames = objEnum.OpenMainConnection

With cmdGetUserNames
Set .ActiveConnection = conGetUserNames
.CommandText = "{call umtest.getoptuname(?,?,?,?,?,?,?)}"
.CommandType = adCmdText

.Parameters(0).Direction = adParamInput
.Parameters(1).Direction = adParamInput
.Parameters(2).Direction = adParamInput
.Parameters(3).Direction = adParamInput
.Parameters(4).Direction = adParamInput
.Parameters(5).Direction = adParamOutput
.Parameters(6).Direction = adParamOutput

.Parameters(0).Value = "mihir"
.Parameters(1).Value = "mihir"
.Parameters(2).Value = "gandhi"
.Parameters(3).Value = #02/12/1977#
.Parameters(4).Value = "India"

.Parameters(5).Type = adNumeric
.Parameters(6).Type = adLongVarChar

Set rsGetUserNames = .Execute
'The above code doesnot generates any error but when i check the recordset it shows the following error.

Error :-
--------
ErrNo:- 3704
Description:-
Operation is not allowed when the object is closed.

Waiting for yr earliest solution.

Mihir

2 replies

by a_schwarze

you need to set the nocount-setting of your sql-server to on. to do this add the line "set nocount on" to the top of your StoredProcedure (and change it back at the end with "set nocount off"
HTH
Andreas

This discussion is closed to new replies.