Solved

stored procedure as class property

Posted on 2006-07-09
4
198 Views
Last Modified: 2010-04-23
I'm trying to build a VB.Net class.
I'd like to show a list of stored procedure read from a database as a property value

example
class name: myclass
property name: storedprocedurelist

myclass.storedprocedurelist.(here I want a list of my stored procedure read from a database)

hoping to be clear
0
Comment
Question by:xtremereality
  • 2
4 Comments
 
LVL 14

Expert Comment

by:Ramuncikas
Comment Utility
If you want a list only then you can expose a property returning a string array. Like

Public MyClass
  Private m_StoredProcedures as String() 'private variable to hold property value

....

  Public Property StoredProcedureList() As String()
    Get
      Return m_StoredProcedures
    End Get
    Set(ByVal value As String())
      m_StoredProcedures = value
    End Set
  End Property

....

End Class

But if you want to have a more object-orientated class witch exposes a collection of objects with their own properties then you have to define a class for a single strored procedure, a class that represents a collection of you stored procedures and add that collection class to your MyClass class.

If you need any further details please let me know
0
 

Author Comment

by:xtremereality
Comment Utility
before my question I tryed something like this:
---------------------------------------------------------------------------------------------------------
Public Class Class1
    Private m_Storedprocedures As Collection = New Collection

    Public ReadOnly Property StoredProcedureList() As Collection
        Get
            Return Populate()
        End Get
    End Property

    Public Function Populate() As Collection
        m_Storedprocedures.Add("sp_sample1")
        m_Storedprocedures.Add("sp_sample2")

        Return m_Storedprocedures
    End Function
End Class
---------------------------------------------------------------------------------------------------------
DRIVER CODE IN ASP.NET PAGE:

Dim oTest As Class1
oTest = New Class1
Response.Write(oTest.StoredProcedureList.Item(1))

But I won't this
---------------------------------------------------------------------------------------------------------

My goal is to have a class that expose me a list of all stored procedure stored into a database.
I arranged an image to show the result I want to obtain at:

http://www.ccna.it/example.jpg

<img src="http://www.ccna.it/example.jpg">

to better explain my goal
0
 
LVL 14

Expert Comment

by:Ramuncikas
Comment Utility
Well, I have never did some kind of stuff before and couldn't find any samples, but I think if you want to have something like your picture shows then your class has to have "hardcoded" these members. But this can make your code to become "buggy" or something like "environment-depending" in case if database's structure changes (e.g. some stored procedures are added or deleted).

As I mentioned earlier I'd suggest you to use ArrayList. The link below has some brief tutorials on how to use arraylist objects:
http://abstractvb.com/code.asp?A=1030
0
 
LVL 96

Accepted Solution

by:
Bob Learned earned 500 total points
Comment Utility
You can define a TypeConverter for the property to retrieve values.

Make a type converter in Visual Basic .NET
http://www.vb-helper.com/howto_net_type_converter.html

Bob
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now