I'm using an asp.net web application with a MySql DB, with the following connetcion string the web.config:
<add name="techConnectionString" connectionString="server=vm-tmysql01;User Id=user;database=tech;password=pass" providerName="MySql.Data.MySqlClient"/>
And this is the code I'm using the get the connection string from the web.config:
System.configuration.configurationmanaget.connectionstrings["techConnectionString"].connectionstring;
For some reason I get the error:
The ConnectionString property has not been initialized. An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
And the stack trace is:
[InvalidOperationException: The ConnectionString property has not been initialized.]
System.Data.SqlClient.SqlConnection.PermissionDemand() +6316916
System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory) +6296606
System.Data.SqlClient.SqlConnection.Open() +300
I'm able to connect to the DB via the Data Sources in Visual Studio and took the ConnectionString from there. I really need some help with it, is there any problem with my connection string?