Author |
Topic |
waveform
Yak Posting Veteran
93 Posts |
Posted - 2011-12-04 : 03:29:16
|
Coming from MySQL, I'm using SQL Server 2008 for the first time. I'd like to just add a login to a database, but I'm finding the screens in SQL Server Manager a little confusing.Could someone please give me a simple step-by-step in how to add a new login to a database? Ie. This is a new user from scratch, the login doesn't exist. They need read/write access to all tables.Thanks and sorry for the newbie question! |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2011-12-04 : 03:37:02
|
http://msdn.microsoft.com/en-us/library/aa337562.aspx------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
waveform
Yak Posting Veteran
93 Posts |
Posted - 2011-12-04 : 04:27:30
|
Thanks Visakh, yes I did try that before posting.The new Database User window asks me to tick "Owned Schemas" as well as "Database Role Membership". I ticked "db_datareader" and "db_datawriter" in both lists.It seems to add the user ok, but I'm getting the error:quote: "System.Data.SqlClient.SqlException: Cannot open database "<dbname>" requested by the login. The login failed. Login failed for user '<username>'".
Under Logins (main security section) the login and password are correct. The connection string is correct. Username is listed under "Users" in the database security section.Everything "seems" correct, but I don't know where to start looking for the problem.What things should I be checking? |
 |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2011-12-04 : 04:28:59
|
quote: Originally posted by waveform Thanks Visakh, yes I did try that before posting.The new Database User window asks me to tick "Owned Schemas" as well as "Database Role Membership". I ticked "db_datareader" and "db_datawriter" in both lists.It seems to add the user ok, but I'm getting the error "System.Data.SqlClient.SqlException: Login failed for user". Under Logins (main security section) the login and password are correct. The connection string is correct.Everything "seems" correct, but I don't know where to start looking for the problem.
did you add a sql login or windows login?------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
waveform
Yak Posting Veteran
93 Posts |
Posted - 2011-12-04 : 04:34:42
|
It was an SQL login.Sorry I typed the wrong error above - see the edited post. Error message is different. |
 |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2011-12-04 : 04:37:26
|
i think you've not added login any role under default database its assigned.Open your login properties and see what role you've assigned to it in database which is shown by error message------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
waveform
Yak Posting Veteran
93 Posts |
Posted - 2011-12-04 : 05:12:22
|
Thanks Visakh, checked it. To make this easier for you, I've taken screen shots. Hope this helps you see what is wrong.Login and User present in Server Security and DB Security lists:http://i.imgur.com/yqylx.gifLogin Properties dialog, showing user in the db mapped to the login, with datareader and datawriter permissions.http://i.imgur.com/m9zEP.gifDatabase User properties:http://i.imgur.com/IVIxY.gifConnection strings tried:Data Source=silverback\sqlexpress;Initial Catalog=Nhat1_db1;uid=nhat1_user1;pwd=<pwd>Server=silverback\sqlexpress;Database=Nhat1_db1;uid=nhat1_user1;pwd=<pwd>[ed] And the error I'm seeing:http://i.imgur.com/LOpdu.gifHope that helps. Looks ok to me but something must be awry. Thank you again. |
 |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2011-12-04 : 05:17:11
|
i think you gave the wrong db name . it says Nhat1_db1 in error message whereas your actual db name is Nhat_db1 as per the screenshot above.------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
waveform
Yak Posting Veteran
93 Posts |
Posted - 2011-12-04 : 05:23:10
|
Ahhh! Geez now I feel silly. Guess I need to get more sleep. :)Thank you so much!And no thread delete button.. how embarrassing. :) |
 |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2011-12-04 : 05:44:43
|
not a problemIt happens to everyone Sometimes it takes a fresh pair of eyes to pick it up------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|