Expand|Select|Wrap|Line Numbers
- Dim rs As ADODB.Recordset
- GetData rs, "sp_TM_GetCurrentRoleTasks", Me.cboRole
- Set Me.cboTask.Recordset = rs
- the middle line changed to:
- GetData rs, "sp_TM_GetCurrentRoleTasks ", CStr(Me.cboRole) & ", " & CStr(Me.txtUserID)
- the Get Data function which had been working fine is:
- Public Sub GetData(ByRef rsIn As ADODB.Recordset, strProc As String, Optional strArgs As String)
- Dim cn As ADODB.Connection
- Set cn = New ADODB.Connection
- cn.ConnectionString = "Provider=sqloledb;Data Source=IUDATA.hscni.net;Initial Catalog=USERS;Trusted_Connection=Yes"
- cn.Open
- Set rsIn = New ADODB.Recordset
- With rsIn
- Set .ActiveConnection = cn
- .ActiveConnection.CommandTimeout = 60
- .Source = strProc & " " & strArgs
- .CursorType = adOpenDynamic
- .LockType = adLockPessimistic
- .CursorLocation = adUseClient
- .Open
- End With
- End Sub
Set Me.cboTask.Recordset = rs
The procedure runs fine in an SQL query window with the source so I don't understand why I'm getting the error.
UPdate: on further investigation, the problem is not with the parameters as I initially thought - but seems to be with the stored procedure returning rowcount messages - even with using NOCOUNT.
final update: the procedure has (suddenly) started working with NOCOUNT behaving as expected. I'm not sure what I've changed so it may be of little help to others. Thanks for trying.