TableAdapter wizard does not have connection string from Settings in pick list
Asked Answered
A

4

7

C# VS 2010 .net v4.0

I add a DataSet to my project (Class Library) and when I try to add a TableAdapter the connection string that I have added to Settings is not available to select. I have connection strings for other datasources (from server explorer) available. I can't use a work around, I NEED to pull the connectionstring from Settings. I do this same thing in many other projects and it usually works, though sometimes I just do random things until I can finally see my connection string. I was hoping the upgrade to vs2010 would fix this. Hopefully someone has seen this and can help, thanks.

Adult answered 9/12, 2010 at 15:23 Comment(2)
More info: I created the dataset in another project that is working then copied it to my problem project. Everything compiles, but when I try to Preview Data in the tableadapter I get: "Unable to find connection 'conn name here' for object 'Settings'. The connection string could not be found in application settings, or the data provider associated with the connection string could not be loaded."Adult
More more info: If I go to some code file and type "Properties.Settings.Default." I do get my connection string in intellisense. So why cant the Dataset find it?Adult
P
2

have you checked the namespace of your project and dataset's designer class? make sure both are same ...

Prostitution answered 23/8, 2011 at 15:28 Comment(0)
T
2

Did the OP ever solve this problem?

I recently had this exact same issue in Visual Studio 2015 (VS2015) and Visual Studio 2017 (VS2017). In previous projects, when adding a DataSet and configuring the TableAdapter, the wizard would show ConnectionStrings that were configured in the Project Settings (which are stored in the app.config. The wizard page would show the name of the string from settings, and the word (Settings) after it to indicate where it came from, as seen here:

enter image description here

However, in a recent project, it would not show the ConnectionStrings from the Project Settings.

It turns out, that in my case, I had copied a previous similar project to use as a shell to start the new project. This included the app.config. I had manually edited a bunch of the files to reflect what was needed for the new project, including the connection string, and I had inadvertently REMOVED a vital value, which was the providerName.

In the app.config, in the ConnectionStrings section, each string needs to specify the name, the ConnectionString AND the providerName. I had accidentally removed the providerName value. Here is an example of the correct settings in app.config

<connectionStrings>
    <add name="MembershipCRM.Properties.Settings.app_ogca_CRMConnectionString"
        connectionString="Data Source=MYSERVERNAME\SQL2014;Initial Catalog=app_ogca_CRM;Integrated Security=True"
        providerName="System.Data.SqlClient" />
    <add name="MembershipCRM.Properties.Settings.app_ogca_QBIConnectionString"
        connectionString="Data Source=MYSERVERNAME\SQL2014;Initial Catalog=app_ogca_QB;Integrated Security=True"
        providerName="System.Data.SqlClient" />
</connectionStrings>

Without the providerName value, indicating which kind of data source the ConnectionString refers to, the TableAdapter Configuration Wizard doesn't think it is valid, and will ignore it. As soon as I added the providerName="System.Data.SqlClient" value back, the wizard immediately picked it up.

Tillo answered 25/10, 2018 at 14:19 Comment(0)
I
1

I had the same issue with vb.net, .net 3.5 and sql 2008. What I did to resolve the issue was go to event viewer and clear the application log. My application log was full. Once I cleared the log I could add and view data connections.

Instructive answered 12/9, 2011 at 18:4 Comment(0)
T
1

I had the same issue. I solved my problem by removing and old reference to the System.dll in the csproj file. screen capture

Taam answered 11/4, 2017 at 14:44 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.