General information
Category:
Database DAO/RDO/ODBC/ADO
Title:
Cursor type changed
I get a "cursor type changed" error from MSSQL Server in the open method of a adodb recordset. That stored procedure performs a simple query of one table, it works well just with that but if I add some lines in the beginig of the code to validate the user it starts returning that error in VB. It works good from de QueryAnalyser and always return only one resultset.
When it gives me that error the recordeset recordcount property returns -1.
I need that recordset from a DCOM so I need it Static ( I guess ), then I referemce it in the client proyect.
here's an exemple VB code that return that error (it's a little diferenct in the DCOM proyect but both do the same):
pd: In the end of the message is the storde procedure script
thanks
Dim conexion As New ADODB.Connection
Dim rs_nomencla As New ADODB.Recordset
Private Sub Command1_Click()
pdo = 55
circ = 1
secc = "a"
chacran = 0
chacral = ""
quintan = 0
quintal = ""
fraccionn = 0
fraccionl = ""
manzanan = 10
manzanal = ""
Dim StrConn As String
If conexion.State = adStateClosed Then
StrConn = "DATABASE=imagenes;" _
& "SERVER=srv_sqldesa;" _
& "DRIVER={SQL SERVER};" _
& "APP=DCOM Planchetas;" _
& "TrustedConnection=Yes;"
conexion.Open StrConn
End If
rs_nomencla.Open "exec buscanomenclatura_mts " + _
"'dpct\adrian', " + _
CStr(pdo) + ", " + _
CStr(circ) + ", '" + _
Trim(secc) + "', " + _
CStr(chacran) + ", " + _
CStr(quintan) + ", " + _
CStr(fraccionn) + ", " + _
CStr(manzanan) + ", '" + _
chacral + "', '" + _
quintal + "', '" + _
fraccionl + "', '" + _
manzanal + "'", conexion, adOpenStatic, adLockReadOnly
If conexion.Errors.Count > 0 Then
For i = 0 To conexion.Errors.Count - 1
MsgBox " Num : " + CStr(conexion.Errors(i).Number) + " Nativerrror : " + CStr(conexion.Errors(i).NativeError) + " Desc:" + conexion.Errors(i).Description
Next
End If
MsgBox " cant res " + Str(rs_nomencla.RecordCount)
End Sub
And here's the Stored procedure :
CREATE PROCEDURE buscanomenclatura_mts
@usuario as char(35),
@partido as smallint,
@v_circuns as tinyint ,
@v_seccion as char(2),
@v_cha1 as smallint,
@v_qui1 as smallint,
@v_fra1 as smallint,
@v_mna1 as smallint,
@v_cha2 as char(3),
@v_qui2 as char(3),
@v_fra2 as char(3),
@v_mna2 as char(3)
as
--user validation
declare @codigo_usuario smallint
declare @codigo_oficina smallint
set @codigo_oficina =0
select @codigo_usuario = codigo_usuario,
@codigo_oficina= codigo_oficina
from usuario
where loginnt= @usuario
if @codigo_oficina =0
return -1 --no existe el usuario en la tabla
if @codigo_oficina <12 and not exists(select * from partido where part_zona= @codigo_oficina and part_cod = @partido )
return -2 --no está autorizado a consultar ese partido
-- end user validation
-- if the lines above are commented it works
select * from plancheta
where
partido= @partido and
circ= @v_circuns and
secc= @v_seccion and
chacra1= @v_cha1 and
quinta1= @v_qui1 and
fracci1= @v_fra1 and
manzan1= @v_mna1 and
chacra2= @v_cha2 and
quinta2= @v_qui2 and
fracci2= @v_fra2 and
manzan2= @v_mna2
GO
Next
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only