Hello,
I am trying to connect to a Sql server database with Blazor client side ( goal is to connect to db behind firewall). I add the System.Data.SqlClient version 4.8.0-preview2.19523.17 that support .Net Core 3.1 (NugetLink ) .
I add this simple code on a Blazore component :
@code {
void WriteToConsole()
{
String connectionString = "Data Source=bieasy.database.microsoft.com;Initial Catalog=adventurework;User ID=etl;Password=GW6%+sYX";
SqlConnection cnn = new SqlConnection(connectionString);
SqlDataReader dataReader ;
cnn.Open();
String sql = "SELECT TOP (1) [AddressID],[AddressLine1],[AddressLine2],[City],[StateProvince],[CountryRegion],[PostalCode],[rowguid],[ModifiedDate] FROM [SalesLT].[Address]";
SqlCommand cmd = new SqlCommand(sql, cnn);
dataReader = cmd.ExecuteReader();
while (dataReader.Read())
{
Console.WriteLine(dataReader.GetValue(0) + " - " + dataReader.GetValue(1) + " - " + dataReader.GetValue(2));
}
dataReader.Close();
cmd.Dispose();
cnn.Close();
}
}
When I run the page I am getting the error : System.PlatformNotSupportedException: System.Data.SqlClient is not supported on this platform. Why can't I use this library ?
Regards
Vincent