0

I am setting up a C# Console Application. I am struggling getting the Database connections set up correctly.

Here is my App.Config :

<add name="ExportVcallData.Properties.Settings.Setting"
     connectionString="Data Source=XXXX;Initial Catalog=XXXX;User ID=XXXX;Password=XXXX"
     providerName="System.Data.SqlClient" />

Here is my Connection string

OdbcConnection con = new OdbcConnection();
con.ConnectionString = System.Configuration.ConfigurationManager  
  .ConnectionStrings["ExportVcallData.Properties.Settings.Setting"]
  .ConnectionString;

I get:

Additional information: ERROR [IM002] [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified

Any Ideas?

mason
  • 31,774
  • 10
  • 77
  • 121
ER.Cons
  • 21
  • 1
  • 6
  • I think I missed the App.Config: – ER.Cons Nov 27 '17 at 18:50
  • 1
    Your provider name is System.Data.SqlClient, you're using a SQL Server connection string, and an OdbcConnection. Do you actually intend to use ODBC? If not, use [SqlConnection](https://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlconnection(v=vs.110).aspx). – mason Nov 27 '17 at 18:53
  • I think @mason is on the right track, you are probably trying to connect to a sql server database based on the content of your connection string. See the marked duplicate for how to create a `SqlConnection` instance. If you really do want an ODBC connection see the other 2 related questions in the duplicate links. – Igor Nov 27 '17 at 19:08
  • And if you want more help you need to provide the details of where you are stuck and include what it is you are actually trying to connect to. – Igor Nov 27 '17 at 19:09
  • Thanks! Very silly error...you all were a big help – ER.Cons Dec 05 '17 at 22:18

0 Answers0