1
Answer

C# obtain linq to sql data

dc

dc

11y
1.7k
1
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)