Adam
Trouble Connecting to Database
I'm using Dapper and SqlClient but I keep getting this error:
Unhandled exception. Microsoft.Data.SqlClient.SqlException (0x80131904): A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: TCP Provider, error: 35 - An internal exception was caught)
here is the code:
15 replies
Error CS0234
using Microsoft.Data.SqlClient;
namespace DataAccessLibrary
{
public class SqlDataAccess
{
private readonly IConfiguration _config;
public string ConnectionStringName { get; set; } = "Default";
public SqlDataAccess(IConfiguration configuration)
{
_config = configuration;
}
public async Task<List<T>> LoadData<T, U>(string sql, U parameters)
{
string connectionString = _config.GetConnectionString(ConnectionStringName);
using(IDbConnection connection = new Microsoft.Data.SqlClient.SqlConnection(connectionString))
{
}
return null;
}
}
}
I get the error on the Microsoft.Data.SqlClient section, I have the package reference in my .csproj here:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Dapper" Version="2.1.35" />
<PackageReference Include="Microsoft.Data.SqlClient" Version="5.2.0" />
</ItemGroup>
</Project>
Any ideas on how to fix this?10 replies
Error CS0103
I am trying to follow this tutorial: https://learn.microsoft.com/en-us/training/modules/blazor-build-rich-interactive-components/2-create-user-interfaces-blazor-components?ns-enrollment-type=learningpath&ns-enrollment-id=learn.aspnet.build-blazor-webapps
and I am getting error CS0103 when trying to use <div @ref="placeHolder"></div> so that "...Blazor render tree doesn't attempt to track its contents. " and I can use the DOM to act on the div.
5 replies