Ham Burg
Ham Burg

Reputation: 79

How to connect with local database

I downloaded SQL Server Management Studio (SSMS). I can connect with local database using Windows Authentication, but I would like to connect with my C# app using connection string.

I check SQL Server Authentication mode here:

Photo

I went to Users tab of my new created database. But I can't add new user. It says that I don't have permission.

I also went to sys user properties, but I can't change password anywhere:

Photo

So what should I do? I want to connect with database on VPS with my c# app.s

Upvotes: 0

Views: 155

Answers (1)

Dillie-O
Dillie-O

Reputation: 29755

If you want to use the current user that is logged in (Windows Authentication) then you setup the connection string as follows:

Server=myServerAddress;Database=myDataBase;Trusted_Connection=True;

If you mean that you want to use a SQL Authenticated account, you need to add the SQL login and user, map it to the database you want, and then you can use the following syntax:

Server=myServerAddress;Database=myDataBase;User Id=myUsername;Password=myPassword;

You can search for more documentation on setting up your App.Config file to have connection strings, and any tweaks to the connection string itself can be found at:

https://connectionstrings.com/sql-server/

Upvotes: 4

Related Questions