ODBC_Connect & instances

Jan 12, 2011 at 12:51 PM

Hey all,

I am using ODBC_Connect for checking if the settings the user providing are correct to connect to Database.

I was wondering if the function can handle Instances on SQL Server.

Does the user have to backslash it within the ServerEditBox, checking the code I didn't find something about escaping backslashing etc.

So is it capable of connecting to SQL Server instances, and if yes how.


Thanks in advance.


Jan 12, 2011 at 4:36 PM

The short answer is yes. You need to construct a connection string that has an instance and no port in ODBC_CONNECTION_STRING. We have this working in production - rather than setting ODBC_CONNECTION_STRING to include the port we set it like this: 

  <!-- Set the default property for ODBC_CONNECTION_STRING -->
  <CustomAction Id="SetDefaultOdbcConnectionString" Property="ODBC_CONNECTION_STRING" Value="Driver={SQL Server};Server=[ODBC_SERVER];Trusted_Connection=Yes;" />

We let ODBC_SERVER be specfied by the user in the input box in the UI. So values can be SERVER or SERVER:PORT or SERVER\INSTANCE and that just works.