Solved

stored procedure as class property

Posted on 2006-07-09
4
225 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

Ready to get started with anonymous questions?

It's easy! Check out this step-by-step guide for asking an anonymous question on Experts Exchange.

Question has a verified solution.

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

I think the Typed DataTable and Typed DataSet are very good options when working with data, but I don't like auto-generated code. First, I create an Abstract Class for my DataTables Common Code.  This class Inherits from DataTable. Also, it can …
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …

623 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