specify odbc connection

I cant beleive i havent found an answer to this, but here goes.

I am using visual studio c++ 2005 express edition and have made an application with a specified data source using an access file. Can I instead setup the odbc connection in Windows and connect to the name of that connection instead All connection strings I have found have forced you to specify the mdb location in the project which is very inflexible and visual studio doesnt seem to let me do it any other way.

Thanks in advance.



Answer this question

specify odbc connection

  • meo1985

    that sounds like it could work, i guess it would tie in with another problem i am having in regards to emulating a partial class in c++, so i can add functionality to the generated dataset.h code which regenerates after every compile, removing any changes the user has made.

    i shall persist >:-|


  • Juan.Faustino

    Hi,

    If you are using ODBC .NET Managed Provider then you could use DSN name in your connection string. You do not have to specify driver name. I do not know C++, but in C# it would look like

    cn= new OdbcConnection("dsn=myDSN;UID=myUid;PWD=myPwd;");



  • pchr

    That sounds like it would work from what i have seen, but i dont think i can do that with the data manager built into visual studio 2005 express edition. I would really like to stick with the in built data management in the ide as it helps reduce user error in the code and is more flexible to change.


  • mthom

    You might want to split the difference -- use the built-in stuff for the majority of the connection string, but leave out the dsn itself, then add that keyword programmatically once you have the file selected.

  • specify odbc connection