Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

stored procedure as class property

Posted on 2006-07-09
4
Medium Priority
?
230 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 2000 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

Enroll in September's Course of the Month

This month’s featured course covers 16 hours of training in installation, management, and deployment of VMware vSphere virtualization environments. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

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

Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…

721 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