dotancohen
dotancohen

Reputation: 31521

Connecting to SQL Server with a username and password

I am writing a C# application to be deployed on another machine. The deploy machine is a clean Windows 7 install.

On my development machine (A Windows 7 32 bit Virtual Machine) I have installed SQL Server 2008 R2 and Visual Studio Express 2010. I would like to create a new database and have it require authentication from an application to connect. All the tutorials that I find mention breeze over the connection string part, I cannot find this explained anywhere. In fact, I cannot even figure out how to add a new user and password to SQL Server in SQL Server Management Studio.

How do I add a new user and password to SQL Management Studio 2008 R2 such that I can easily install another SQL Server instance on another machine and move the database to it?

Thanks.

Upvotes: 2

Views: 22497

Answers (2)

Diego
Diego

Reputation: 36176

first check the authentication mode of your DB: connect to your DB on SSMS, right click it, go to "properties" and then "security". Make sure that "SQL Server and windows authentication mode" is selected. That will allow you to create logins.

Then create your login: connect to your DB on SSMS, expand your database then go to "security" and right click on logins and then click "new login"

then create your user: go to the security folder inside your DB, right click users and "new user". Inform the user name and the login name you previous created. Dont forget to add the necessary permissions

About connection strings, this is a very good website as already pointed:

http://www.connectionstrings.com/

Upvotes: 2

Matthew Sanford
Matthew Sanford

Reputation: 1099

To create a SQL Server Login:

http://msdn.microsoft.com/en-us/library/aa337562.aspx

For Connection strings:

http://www.connectionstrings.com/

Upvotes: 2

Related Questions