Click to See Complete Forum and Search --> : How to design a middle level object like ADO


Andrew Luit
December 8th, 1999, 01:44 AM
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

Lothar Haensler
December 8th, 1999, 02:06 AM
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...

Andrew Luit
December 8th, 1999, 07:36 PM
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?

Lothar Haensler
December 9th, 1999, 01:52 AM
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

Andrew Luit
December 9th, 1999, 02:17 AM
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.

Lothar Haensler
December 9th, 1999, 02:19 AM
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.

Andrew Luit
December 9th, 1999, 04:59 AM
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.