More than 1 data source

mvanhelmont

New member
Joined
Jul 17, 2005
Messages
2
Programming Experience
1-3
Maby sombody ken help me. I am devloping a database program but i what dat the customer can choice which data source he whant to use.

I what to create a access database source a sql data source and a webservice source.

But i stuck on how i must manage this. I must create a select case and than is the case is SQL i must use de SQL commando's and when it the case is access i whant to use the access commando's.

Got sombody any idee how i can solve the problem?

I use MDI forms so i think i must create a class file for my connection's?

Thanks,

Marcel van Helmont
 
All you need is few radio buttons (3 in this case). Then just chech which was checked. For instance say user has selected 1st radio button and want to get data from an access DB.
VB.NET:
If rb1.Checked = true then 
conn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Application.StartupPath & "/myDB.mdb; Persist Security Info=False;"
ElseIf rb2.Checked = true then 
conn = "Data Source=myServer;Initial Catalog=pubs;Integrated Security=SSPI;" 
'and so on
{...}
the rest of the code remains the same (if both DB structures are identical) ... means you just need to change a data source, that's it.

Cheers ;)
 
Depending on what databases you want to support, you may need to change the Data namespace, e.g. System.Data.SqlClient for SQL Server and System.Data.OleDb for Access. There are various third-party database-independent data access layers available off the Net, or you could write your own. The functionality for determining the correct data access classes to use is contained within the DAL, so you can use it without regard for what database is on the other side.
 
Back
Top