Stashing ConnectionString in class

I have a class that initializes with a Connection String that various functions in the class use to access the SQL Database referenced. Currently the class stashes the passed in ConnectionString in a private readonly string. As I am writing the using statement for the hundredth time in the functions: using (SqlConnection SQLCon = new… Read More Stashing ConnectionString in class

Asp.NET – connectionString error while trying to connect with Microsoft SQL Server Management Studio (SQLEXPRESS)

I am trying to make a connection between my Asp.NET project and Microsot SQL Server Managment Studio. Just following a tutorial from freeCodeCamp : Learn ASP.NET Core MVC (.NET 6) – Full Course. My problem began in 1:31:51 But I guess my connectionString doesn’t work: "ConnectionStrings": { "DefaultConnection": "Server=.\\SQLEXPRESS;Database=Bulky;Trusted_Connection:True;" } Error: Format of the initialization… Read More Asp.NET – connectionString error while trying to connect with Microsoft SQL Server Management Studio (SQLEXPRESS)

System.NotSupportedException: 'The given path's format is not supported.'

string dbPath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments); dbPath = Path.Combine(dbPath, "Database1.mdf"); cn = new SqlConnection (@"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=|DataDirectory| "+dbPath+";Integrated Security=True"); GetAllRecords(); When I run this code, it displays this error System.NotSupportedException: ‘The given path’s format is not supported.’ I want to connect the database located in current user’s document folder. How to fix this? >Solution : The AttachDbFilename attribute… Read More System.NotSupportedException: 'The given path's format is not supported.'