id="info"

Question

Locked

How to use 1 objectvariable for more than 1 class in vb.net 2008

By pancras ·
In a program i have a class that does the database interaction (clsSQLs). So if i want to write to a table i call the method:

public MyInst as clsSQLs
sub main
myinst=new clsSQLs
.
.
sub inLotsOfOtherSubs
MyInst.WriteCustomer("ANATR",etc.)

This class is written to communicate with sqlserver through calling stored procedures.
I want to extend the program to use
textFiles and Access in a such a way that through a switch i can let the program talk to SQLServer, Access or textFiles.
I could create 2 extra classes clsText and clsACCESS with the same interface as clsSQLs but with text and Access specific handling.
And then do something like
select case Switch
case "sqlServer"
myinst=new clsSQLs
case "Text"
myinst=new clsText
case "access"
myinst=new clsAcces

How to go about that without losing intellisense?
('public MyInst as object' will probably work, i have not tested that)
Thanks in advance

This conversation is currently closed to new comments.

2 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Answers

Back to Software Forum
2 total posts (Page 1 of 1)  

Software Forums