Solved

stored procedure as class property

Posted on 2006-07-09
4
217 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 14

Expert Comment

by:Ramuncikas
ID: 17068619
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
ID: 17068777
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
ID: 17068925
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
ID: 17069059
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

734 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