473,394 Members | 1,696 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Determine Object Type From Database

Dan
All,

I am working on an application that allows users to track
various items for various clients. For example Client A
may have an object Box where Client B has an object
Canister. When a user goes to enter a new object I would
like the application to determine what objects are
available based upon the client (easy enough) and when
they determine what object to enter the program would know
that it needed to instantiate an object of that type. For
example, the user selects Client A and object Box the
program would instantiate an object of type Box. I want to
avoid hardcoding this into the application so that way if
I need to add object of type Carton later on I can insert
that object into the database, distribute a DLL for that
object, and the program would be able to instantate
objects of the type canister.

Does anyone have any idea if this is possible to do and if
so how? Any suggesions would be greatly appreciated.
Thanks!
Nov 15 '05 #1
1 2266
Sounds to me like the database is not a central issue in this problem.
Getting the name of the type from the db is pretty simple, and I'll guess
that is not what is puzzling you.

What you seem to be asking for, is a way to instantiate types, selecting the
implementation of the type dynamically, at runtime.
You can do this via the System.Activator.CreateInstance() method, or via
Reflection with the System.Type.CreateInstance()
Check the archives of this group for tips .

You'll probably want to use interfaces to construct your extensible object
model, and employ a Factory pattern.
eg,
http://www.superdotnet.com/Article.aspx?ArticleID=158

suggestion: google for "factory CreateInstance interface"

--
Dino Chiesa
Microsoft Developer Division
d i n o c h @ o n l i n e . m i c r o s o f t . c o m

"Dan" <dd*****@fnisolutions.com> wrote in message
news:14****************************@phx.gbl...
All,

I am working on an application that allows users to track
various items for various clients. For example Client A
may have an object Box where Client B has an object
Canister. When a user goes to enter a new object I would
like the application to determine what objects are
available based upon the client (easy enough) and when
they determine what object to enter the program would know
that it needed to instantiate an object of that type. For
example, the user selects Client A and object Box the
program would instantiate an object of type Box. I want to
avoid hardcoding this into the application so that way if
I need to add object of type Carton later on I can insert
that object into the database, distribute a DLL for that
object, and the program would be able to instantate
objects of the type canister.

Does anyone have any idea if this is possible to do and if
so how? Any suggesions would be greatly appreciated.
Thanks!

Nov 15 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Lenard Lindstrom | last post by:
I was wondering if anyone has suggested having Python determine a method's kind from its first parameter. 'self' is a de facto reserved word; 'cls' is a good indicator of a class method ( __new__...
18
by: Christopher W. Douglas | last post by:
I am writing a VB.NET application in Visual Studio 2003. I have written a method that handles several events, such as closing a form and changing the visible status of a form. I have some code...
11
by: DrUg13 | last post by:
In java, this seems so easy. You need a new object Object test = new Object() gives me exactly what I want. could someone please help me understand the different ways to do the same thing in...
3
by: Tor Erik Sønvisen | last post by:
Hi How can I determine the type of a socket (TCP or UDP) object? regards tores
1
by: scj | last post by:
Hi all, I need to determine the exact type of DateTime column(*) in an Access 97 database. I'm able to do this with an Access 2 database. With ADO.Net and VB.Net (**), I do something like...
0
by: Siegfried Heintze | last post by:
This program works fine on my desktop when I grant full control of the MSAccess database to everyone. However, when I put it on my hosting service with no impersonation, I now get this error (see...
5
by: MLH | last post by:
Suppose MyName, a string variable equals "frmEnterClients". How can I determine ... 1) if frmEnterClients exists as an object in the database? 2) what type of object is it (tbl, qry, frm, rpt,...
0
by: Hetal | last post by:
Hi.. I have a VB.NET (Windows forms) application and i would like to determine the type of database (SQL/MySQL/Access) i am connected to. In native VB6, say i have a connection object named...
1
by: mark_aok | last post by:
Hi all, I have a situation where I need to determine a specific table's primary key, and then output it. I have tried the Database Object, and the Record Object, but I've had no luck. ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.