Dynamically calling to a MySQL, MSQL, DB2, or Oracle Database in code RRS feed

  • Question

  • I'm trying to write functional nunit test code for XFIRE-created web services and I need to be able to connect to MySQL, MSQL, DB2, or Oracle databases for setup and tear down SQL comands (set, delete mostly) before running the various tests. 

    Is there a way to connect to all of these various database types with one library or method?  I'm having little luck finding anybody who is trying to do this.  (could be a clue, right?)  I was looking into LINQ but I can't figure out if it's what I need or documentation on HOW to set up the connections. 

    Many thanks for any help you can offer.

    Tuesday, May 20, 2008 8:04 PM

All replies

  • Hi Drake


    In traditional terms, if you stick to ANSI92 SQL and don't want to harness anything specific to each database technology, the only difference will come with the connection string. It should be relatively straightforward to put together a little library which handles this and switches connection strings depending on the target database platform.


    This is the beauty of having data providers sitting between a data access class and a database, since it handles most of the differences for you. The same is true of LINQ in that it is loosely coupled with the target data source.


    Best regards




    Tuesday, May 20, 2008 9:32 PM
  • Im not 100% sure I understand your question but I have a couple of suggestions. It sounds like what you may need to do is use an ODBC connection to get the data that you want. There is a patch available,  for VS2005 at least, that will let you add fully managed OdbcDataAdapters to your project. You can then connect to what ever datasource that you want.

    As far as connection strings are concerned I have found http://www.connectionstrings.com/ to be quite usefull for getting the exact syntax needed for some lesser used datatbases.

    I hope that this helps out. Good luck!
    Tuesday, May 20, 2008 10:42 PM
  • Thanks guys, I think one or both of your solutions would apply. 
    Sunday, May 25, 2008 1:50 PM