G
Guest
Hi all!
Up to now, I was working with a SQL Server 7 and VBSQL. It was easy to call
a stored procedure with (usually) a SELECT parameter and retrieve a cursor
from the stored procedure.
As I am in the process to migrating to a SQL 2005 Server, I can't use VBSQL
anymore.
What I try to do is as follows:
I have a stored procedure like "SELECT * FROM <Table> WHERE <Table.Field> =
@Parameter"
I would like to retrieve a cursor (ADODB.Recordset) when calling that
procedure.
I tryied somothing like this but it does not work:
Dim cnnTest As New ADODB.Connection
Dim rstTest As New ADODB.Recordset
Dim strCnn As String
Dim prp As ADODB.Property
strCnn = "driver={SQL Server};SERVER=BRAVO-N;DATABASE=TEST_ADO;
Trusted_Connection=yes"
rstTest.CursorType = adOpenKeyset
rstTest.LockType = adLockOptimistic
' Open Table
'
Rem rstTest.Open "Table_1", strCnn, , , adCmdTable
' Open stored procedure (without parameter)
'
' rstTest.Open "NewSelectCommand", strCnn, adOpenDynamic,
adLockOptimistic
' Open stored procedure (with parameter)
'
Set prmAddress = rstTest.CreateParameter("Address", adUnsignedInt,
adParamInput, 4)
rstTest.Parameters.Append prmAddress
prmAddress.Value = 1
rstTest.Open "Test", strCnn, adOpenDynamic, adLockOptimistic
Do Until rstTest.EOF
MsgBox rstTest!col_1 & " : " & rstTest!col_2, , "TestADO_Recordset"
rstTest.MoveNext
Loop
rstTest.Close
Set rstTest = Nothing
When I try to call that function I receive an error message, at the line
"Set prmAddress = rstTest.CreateParameter("Address", adUnsignedInt,
adParamInput, 4)", saying that this member or method is not available.
What's wrong? I understand that, obviously, a recordset does not have a
parameters collection. But what have I to do? Do I have to use an
ADODB.Command to call the stored procedure? And if yes, how do I get a
cursor (recordset) from it?
Please help, I'm very confused right now.
Up to now, I was working with a SQL Server 7 and VBSQL. It was easy to call
a stored procedure with (usually) a SELECT parameter and retrieve a cursor
from the stored procedure.
As I am in the process to migrating to a SQL 2005 Server, I can't use VBSQL
anymore.
What I try to do is as follows:
I have a stored procedure like "SELECT * FROM <Table> WHERE <Table.Field> =
@Parameter"
I would like to retrieve a cursor (ADODB.Recordset) when calling that
procedure.
I tryied somothing like this but it does not work:
Dim cnnTest As New ADODB.Connection
Dim rstTest As New ADODB.Recordset
Dim strCnn As String
Dim prp As ADODB.Property
strCnn = "driver={SQL Server};SERVER=BRAVO-N;DATABASE=TEST_ADO;
Trusted_Connection=yes"
rstTest.CursorType = adOpenKeyset
rstTest.LockType = adLockOptimistic
' Open Table
'
Rem rstTest.Open "Table_1", strCnn, , , adCmdTable
' Open stored procedure (without parameter)
'
' rstTest.Open "NewSelectCommand", strCnn, adOpenDynamic,
adLockOptimistic
' Open stored procedure (with parameter)
'
Set prmAddress = rstTest.CreateParameter("Address", adUnsignedInt,
adParamInput, 4)
rstTest.Parameters.Append prmAddress
prmAddress.Value = 1
rstTest.Open "Test", strCnn, adOpenDynamic, adLockOptimistic
Do Until rstTest.EOF
MsgBox rstTest!col_1 & " : " & rstTest!col_2, , "TestADO_Recordset"
rstTest.MoveNext
Loop
rstTest.Close
Set rstTest = Nothing
When I try to call that function I receive an error message, at the line
"Set prmAddress = rstTest.CreateParameter("Address", adUnsignedInt,
adParamInput, 4)", saying that this member or method is not available.
What's wrong? I understand that, obviously, a recordset does not have a
parameters collection. But what have I to do? Do I have to use an
ADODB.Command to call the stored procedure? And if yes, how do I get a
cursor (recordset) from it?
Please help, I'm very confused right now.