Automating Database connection
-
Hi experts! my query is.. can we create a dynamic conncation string at run time... no matter to which database we r connecting to.. it may be SQL server, Oracle, MYSQl, ACCESS... etc. when ever i execute my appplication... the user shud be able to choose from the available drivers.... to which database they want to make connection ... like a wizard. i am using VB 6.0. Or is it possible that ... the wizard which Microsoft provides for connection string...cud be called directly into the application.. from which connection shud be made automatically depending upon which database does the user has selected... is there any aPI to handle this!!! the reason.. i m askin this.. is to avoid the massive chunk of code to be written! which is surely gonna hang me up in the office for next couple of weeks! Any suggestions please...!! thanx in advance..!
-
Hi experts! my query is.. can we create a dynamic conncation string at run time... no matter to which database we r connecting to.. it may be SQL server, Oracle, MYSQl, ACCESS... etc. when ever i execute my appplication... the user shud be able to choose from the available drivers.... to which database they want to make connection ... like a wizard. i am using VB 6.0. Or is it possible that ... the wizard which Microsoft provides for connection string...cud be called directly into the application.. from which connection shud be made automatically depending upon which database does the user has selected... is there any aPI to handle this!!! the reason.. i m askin this.. is to avoid the massive chunk of code to be written! which is surely gonna hang me up in the office for next couple of weeks! Any suggestions please...!! thanx in advance..!
A connection string is nothing but a normal string of text. You need to have template strings for all the database engines you're going to support. You can find examples at http://www.connectionstrings.com[^]. After that, you'd have to write a data layer for each database engine you're supporting too. Access doesn't support the same SQL syntax that SQL Server does and Orcale has it's own flavor too. Each version of this data layer would implement an Interface that you write to provide all the functions you need. To support all this, you wouldnt be saving yourself frmo writing a "massive chunk" of code, you'd be guaranteeing it.
A guide to posting questions on CodeProject[^]
Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
2006, 2007