2

We have an old project that has been running for over 10 years, and now we tried to update parts to net standard 2.0. Earlier it was possible to set a connection in the DataSet that could be changed with an entry in web.config.

If you check the old generated xxxDataSet.Designer.cs it looks this

private void InitConnection() {
            this._connection = new global::System.Data.SqlClient.SqlConnection();
            this._connection.ConnectionString = global::Sparkle.Data.DataSets.Properties.Settings.Default.DefaultDatabase;
        }

So a reference to the DefaultDatabase that could be changed in the web.config

When we try to do the same thing in Net Standard 2.0 we get this:

        private void InitConnection() {
            this._connection = new global::System.Data.SqlClient.SqlConnection();
            this._connection.ConnectionString = "Data Source=tcp:xxx.database.windows.net,1433;Initial Catalog=Dev;Persi" +
                "st Security Info=True;User ID=xxxx;Password=xxxxx";
        }

We do know if this is a change for Net Standard 2.0 or if it change of Visual Studio version. When we search we can se a lot of references to that you can set the ConnectionString on the table adapter, but it is Private in our case, so not possible to change.

We use the DataSet project from an Asp.Net project that is .Net Framwork 4.8.

We cannot get the DataSet-wizard to set a reference to the ConnectionString.

Is it possible to set a reference to a ConnectionString and not the acctual ConnectionString? Or what is the preferred method of doing this when you have multiple of databases

Hoben
  • 49
  • 3
  • Did you ever find a solution to this? We have the same problem, migrating a library from .NET 4.8 to .NET Standard 2.0. Can't get the designer to use a connection string from the settings file or app.config. – Simon Gymer Aug 20 '21 at 13:41

0 Answers0