CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 7 of 7
  1. #1
    Join Date
    Oct 1999
    Location
    Shenzhen, P.R.China
    Posts
    35

    How to design a middle level object like ADO

    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


  2. #2
    Join Date
    May 1999
    Posts
    3,332

    Re: How to design a middle level object like ADO

    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...


  3. #3
    Join Date
    Oct 1999
    Location
    Shenzhen, P.R.China
    Posts
    35

    More detailed info

    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?


  4. #4
    Join Date
    May 1999
    Posts
    3,332

    Re: More detailed info

    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


  5. #5
    Join Date
    Oct 1999
    Location
    Shenzhen, P.R.China
    Posts
    35

    Re: More detailed info

    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.


  6. #6
    Join Date
    May 1999
    Posts
    3,332

    Re: More detailed info

    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.


  7. #7
    Join Date
    Oct 1999
    Location
    Shenzhen, P.R.China
    Posts
    35

    I tried, but failed.

    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.



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured