dc

dc

  • NA
  • 629
  • 0

C# obtain linq to sql data

Jan 30 2013 1:01 AM
In a C# 2010 windows application, I am getting the following error message:

"The connection property in the Application Settings file is missing or incorrect. The connection string from the .dbml file has been used in its place".
I am also getting the warning message:  warning CS0618: 'System.Configuration.ConfigurationSettings.AppSettings' is obsolete: 'This method is obsolete,
it has been replaced by System.Configuration!System.Configuration.ConfigurationManager.AppSettings".

What I am trying to do is obtain the connection string information from the app.configuration file instead from the app settings file.

To accomplish this goal I am changing the *designer.cs to use the following code to obtain the connection string information:

base(ConfigurationManager.ConnectionStrings["DEVConnectionString"].ConnectionString, mappingSource)

The app.configuration file looks like the following:
<connectionStrings>
    <add name="DEVConnectionString" connectionString="Data Source=dev2008;Initial Catalog=DEV;Integrated Security=True"
      providerName="System.Data.SqlClient" />
  </connectionStrings>

The above code works fine when I setup the code initially.
However once I reopen the solution file, I get the message listed above,
""The connection property in the Application Settings file is missing or incorrect.
The connection string from the .dbml file has been used in its place".

To solve this problem, I was trying to do the following steps:
1.Step 1: Right click on the .DBML file and select "Run Custom Tool".
2.Step 2: Set "Application setting = false" in the connecton properties of your DataContext.
3.Step 3: press "Save All".


The problem with the above solution is once I selected "Run Custom Tool", nothing happened. There was nothing for me to select.

Thus can you tell me and/or show me in code how to solve this problem?

Answers (1)