locked
OdbcConnection: System DSN and User DSN with the same name RRS feed

  • Question

  • Situation:

    .NET Desktop-Application that instantiates an OdbcConnection and passes the connection string which contains the "dsn=xxxx" part. On the client PCs there are situations where both a system DSN and a user DSN exists. There seems to be no way to specify which of the two existing DSN with the same name should be taken.

    Question:

    Are there deterministic rules  to decide if the system DSN or user DSN is used? Or can this be set within the connection string? 

    Thank you for your help

    Tuesday, September 9, 2014 8:00 AM

Answers

  • Hello KloonSwitzerland,

    >>Are there deterministic rules to decide if the system DSN or user DSN is used?

    As far as I know, the program would look for the user DSN list, if program does not find any matched entry, the program would look for the system DSN list to find the matched entry since the system DSN is shared in the machine.

    >>Or can this be set within the connection string?

    If both of them actually connect to the same database, I think you do not need to pay attention to it.

    If not, it is recommended to use a different DSN name. Or use this connection string to specify the connected database explicitly:

    string connectionString = @"Driver={SQL Server Native Client 11.0};Server=(localdb)\Projects;Database=DFDB;Integrated Security=True;Trusted_Connection=Yes;";

    You need to replace properties with yours as Driver(if you do not use SQL Server), Server and Database. If you want to know more, you could refer to this link:

    http://www.connectionstrings.com/sql-server-native-client-11-0-odbc-driver/

    If I misunderstand, please let me know.

    Best Regards,

    Fred.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.


    • Edited by Fred Bao Wednesday, September 10, 2014 1:55 AM
    • Marked as answer by KloonSwitzerland Wednesday, September 10, 2014 1:08 PM
    Wednesday, September 10, 2014 1:51 AM