Danylo Bilokha
Danylo Bilokha

Reputation: 115

Cannot use using construction to connect to SQL Server in UWP application

I have such errors:

enter image description here

or description who don't want to use link:

Severity Code Description Project File Line Suppression State Error CS7069 Reference to type 'Component' claims it is defined in 'System', but it could not be found Reporting_UI_UWP C:\Users\beloh\Desktop\OLSOM\AVOA\AVOAReport\VS_0.1.0\Reporting_UI_UWP\SQL\SQL.cs 33 Active Severity Code Description Project File Line Suppression State Error CS7069 Reference to type 'ICloneable' claims it is defined in 'mscorlib', but it could not be found Reporting_UI_UWP C:\Users\beloh\Desktop\OLSOM\AVOA\AVOAReport\VS_0.1.0\Reporting_UI_UWP\SQL\SQL.cs 33 Active

when write that's code:

using (SqlConnection conn = new SqlConnection(defConnString))
{
}

defConnString is defined and System.Data.SqlClient imported.

When I'm use that code:

SqlConnection conn = new SqlConnection(defConnString);

all is ok.

What's the problem?

Upvotes: 0

Views: 455

Answers (2)

Stefan Wick  MSFT
Stefan Wick MSFT

Reputation: 13850

For this scenario to work, you need the following configuration:

  • Visual Studio 2017 Update 4 (or later)
  • Min version in your UWP project 16299 (=Fall Creators Update)
  • NETCore version 6.0 (or later)

Here is a sample app.

Here is the session at Microsoft Ignite 2017 where we demo'ed it.

Upvotes: 1

Ipsit Gaur
Ipsit Gaur

Reputation: 2927

SqlConnection lies in System.Data.SqlClient namespace which is not available in UWP.

You can only use the APIs for UWP apps provided by Microsoft. Refer to Windows Runtime (WinRT) APIs.

Upvotes: 0

Related Questions