So im trying to connect to an sql server database and i have to type in the connection string but the problem is idk how to format the string since it has the path to the db file which has slashes so any help would be more than appreciated

What do you mean by “I have to type in the connection string”?
Your users should not have to type in connection strings, most users would struggle to do this. But if they do, neither you nor they should have to worry about slashes or backslashes or anything like that.

Or do you mean that you need to put the connection string into your program? This is generally considered bad practice, but if you have to do it, then put an @ sign before the string like this:

Far better would be to put the connection string into a configuration file. This is whole topic in itself (but not a particular difficult one), but the most common configuration files are JSON files, where you double-up each backslash:

Edit: there are loads of documents and blog posts on how to add a configuration file, but I found this one just as an example, to get you started
When i make an object of sqlconnectiom i have to pass in the connection string and it seems to be breaking my code although i copied it from the properties window

source