user1968481
user1968481

Reputation: 43

SQL Server authentication for a Database file

I use Microsoft Visual Studio Professional 2013. I created Database1.mdf in my App_Data folder. By default, it uses integrated Windows authentication. I have no problem connect to this database file, but when I update all file into web space and browse it in browser, it has an error. I think I need to change it to SQL Server authentication instead of integrated Windows authentication.

My questions are:

  1. How can I change it to SQL Server authentication step by step? I want to connect this data file with user name & password.

  2. How to assign user into it?

Upvotes: 1

Views: 857

Answers (1)

Dalorzo
Dalorzo

Reputation: 20024

You need to attach the database file to your SQL Server:

http://www.youtube.com/watch?v=rhIr9Qf-oHw

Then you create the type of logins you want:

http://www.youtube.com/watch?v=Uh5USR7pymE

You can now detach the database. Your application can use now the new logins. If you change from Windows to User/password your connection will need to say so, something like:

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

I also found this helpful link that describes also the steps:

SQLExpress - How do I set username/password for a sql datafile

Hope this helps.

Upvotes: 3

Related Questions