How to design a class that can excute a stored procedure in the server and accept a set of records from the stored procedure. It looks like ADO.
Thanks in advance
Printable View
How to design a class that can excute a stored procedure in the server and accept a set of records from the stored procedure. It looks like ADO.
Thanks in advance
in VB6 you can add a class to your project and select "Data Source" as Class Type.
This will add a class module with properties like:
DataSourceBehavior = vbDataSource
...and add a class member function GetDataMember
In your class write regular ADO code...
Can you give more detailed information in the GetDataMember and in the stored procedure?
.How does the function GetDataMember receive a record set from the procedure runing in the server?
.How can a stored procedure return a record set to VB program?
.Can you give me a pseudo code?
ok, here is some pseudocode
public function GetDataMember (..) as ADO.Recordset
dim rs as ado.recordset
dim cmd as ado.command
set cmd.activeconnection = yourconnectionobject
cmd.Commandtype = adcmdStoredProc
cmd.CommandText = yourspname
cmd.parameters.refresh
cmd.parameters(...).value = ... ' fill your params here
rs.Open cmd
set getDataMember = rs
end function
The expected functionality of the "middle level" is to accept a group of records from a stored procedure. If the client is like your psuedo code, what does the procedure look like?
Thanks.
well, the code I posted refers to the middle tier, i.e. the one that returns the recordset to the client.
What the client code looks like?
it could really be no code!
no kidding. If you use an ADO Data Control you could just set the DataMember property of that control accordingly and, voila, get the data without writing any code.
I tried follow you, but I failed to get a recordset.
I defined a variable as ROWTYPE%, and select * into the variable from <a table> where clause to ensure that there is only one record is selected.
But on the client, after rs.open cmd, the recordset rs is garbage.
If your solution do work, please give me a detailed explaination.
.How to write the procedure
.How to set the DataMember property.
Thanks.