sql - Exception "Data source name not found" while connecting to an existing DSN -


i have created odbc connections (both 32/64 bit) configuration given below:

microsoft sql server odbc driver version 10.00.14393  data source name: odbcmssql data source description:  server: .\sqlexpress database: medicalmarketting language: (default) translate character data: yes log long running queries: no log driver statistics: no use regional settings: no prepared statements option: drop temporary procedures on disconnect use failover server: no use ansi quoted identifiers: yes use ansi null, paddings , warnings: yes data encryption: no 

i want connect local mssql server given in below code snippet:

        string connectionstring = "data source=odbcmssql;initial catalog=medicalmarketting;integrated security=true";         con = new odbcconnection(connectionstring);         cmd = new odbccommand();         cmd.connection = con;         cmd.commandtype = commandtype.text;         try         {             this.con.open();             this.tr = con.begintransaction();             this.cmd.transaction = tr;         }         catch (exception ex)         {                 this.rollback();         } 

this throws exception has error message below:

error [im002] [microsoft][odbc driver manager] data source name not found , no default driver specified

sorry if basic, had post clue because same configuration different odbc connections works perfectly.

i found quick fix problem changing connection string to,

string connectionstring = "dsn=odbcmssql";// best practice store in seperate config file. 

in fact, other attributes specified (initial catalog, integrated security) not odbc connection string attributes, hence ignored. full list of odbc connection attributes can found below.

https://msdn.microsoft.com/en-us/library/ee275047(v=bts.10).aspx


Comments

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -