Follow via:
RSS
Email Alert
Question
0 Votes
+ -

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

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


Tags: programming
Updated - 20th Nov 2009
Answer the question
Formatting +
BB Codes - Note: HTML is not supported in forums
  • [b] Bold [/b]
  • [i] Italic [/i]
  • [u] Underline [/u]
  • [s] Strikethrough [/s]
  • [q] "Quote" [/q]
  • [ol][*] 1. Ordered List [/ol]
  • [ul][*] · Unordered List [/ul]
  • [pre] Preformat [/pre]
  • [quote] "Blockquote" [/quote]

Join the TechRepublic Community and join the conversation! Signing-up is free and quick, Do it now, we want to hear your opinion.