August 8, 2014 at 7:58 am
I had to database one on my local machine (LM) and one on the network machine (NM).
NM had a website where users and had to login to access the data using SQL authentication.
LM uses windows authentication. I updated LM made a backup.
detach NM and delete it. I copied the backup to NW and then Attach it.
now when users login they are seeing the message can't find database.
Even if I know for a fact the database is there with the same name.
Not sure what to do.
August 8, 2014 at 8:06 am
Do both databases have the same name?
How can you connect to the DB restored on the NM (Mixed Mode or Windwos authentication only)?
In case of mixed mode: Did you add all SQL user from the original db to the new db? If not, the SQL login most probably won't work anymore....
August 8, 2014 at 8:14 am
both databases has the same name
the users are in the configuration file on the network website
<add name="DefaultConnection" connectionString="Data Source=xxxx;Initial Catalog=aspnet-cxcDB-20130627224632.mdf;User ID=xxxx;Password=xxxxx" providerName="System.Data.SqlClient" />
<add name="CXCDBConnectionString1" connectionString="Data Source=xxxx;Initial Catalog=CXCDB;User ID=xxxx;Password=xxxx" providerName="System.Data.SqlClient" />
[Edited by Administrator]
August 8, 2014 at 8:28 am
earlcools (8/8/2014)
both databases has the same namethe users are in the configuration file on the network website
<add name="DefaultConnection" connectionString="Data Source=xxxxx;Initial Catalog=aspnet-cxcDB-20130627224632.mdf;User ID=xxxxxx;Password=xxxxx" providerName="System.Data.SqlClient" />
<add name="CXCDBConnectionString1" connectionString="Data Source=xxxx;Initial Catalog=CXCDB;User ID=xxxxx;Password=xxx" providerName="System.Data.SqlClient" />
I URGENTLY REQUEST YOU to remove the real connection string immediately from your post!!!
Obfuscate it, if needed!
Otherwise you'll be in BIG TROUBLE in almost no time!!!!
August 8, 2014 at 9:50 am
thanks
August 8, 2014 at 10:19 am
I've seen you're using the most dangerous connection string possible.
This is absolutely the wrong way to connect to a database.
Create a SQL login limited to the database the application needs access to. Create a group within the database and put that SQL login into that group.
Allow only access to the group and the stuff that's really needed. E.g., specifically name the tables/views the app has SELECT permissions and/or the sprocs the app is allowed to execute.
Once you're able to connect to the database using Management Studio and the login you just created, change the connection string to the new login.
Another option:
If this is an Intranet solution, you could also change the connection string to use a trusted connection (=Windows authentication).
Ask your domain admins to create an AD group for users that are allowed to use the application.
At the SQL Server side, add the AD group to the SQL group and you should be all set.
August 8, 2014 at 4:43 pm
Even if the new server has all the sql logins on it, the SIDs of the users in the database are different, because the logins were created on a different server.
In the attached database, run:
ALTER USER UserName WITH LOGIN = LoginName
for each user associated with a sql login
August 8, 2014 at 4:43 pm
August 11, 2014 at 1:29 pm
ALTER USER UserName WITH LOGIN = LoginName
I am sorry I could not get it to work.
A little more explanation please.
August 11, 2014 at 2:28 pm
First, you need to create all the logins on NM that are used in the db you copied there. You can script out the logins from the old server, but you'll need to correct the password and remove any "DISABLE" login statements. [You can add the login's current SID on the CREATE LOGIN statement if you'll need to keep going from one server to another, as that will making sync'ing automatic.]
Then, if you didn't copy the existing SIDs, you'll need to run the ALTER USER command for every user to re-sync it to its login.
SQL DBA,SQL Server MVP(07, 08, 09) "It's a dog-eat-dog world, and I'm wearing Milk-Bone underwear." "Norm", on "Cheers". Also from "Cheers", from "Carla": "You need to know 3 things about Tortelli men: Tortelli men draw women like flies; Tortelli men treat women like flies; Tortelli men's brains are in their flies".
August 11, 2014 at 2:32 pm
Assuming the database user names are the same as the login names,
for each login name/database user name in the the attached database, run:
USE <db_name_here>
GO
ALTER USER <login_name> WITH LOGIN = <login_name>
GO
August 11, 2014 at 2:34 pm
It looks like you have already the logins there, since the failure is "could not open database"
If not, do as Scott suggested.
August 11, 2014 at 2:48 pm
I have two databases one with the users and the other with the data
After the user login
if the user is james it say
Cannot open database "Database" requested by the login. The login failed.
Login failed for user 'james'
it cannot open the databases with the data. the one with the user is working fine.
August 11, 2014 at 3:41 pm
Does the user "james" has the permission to connect to database "data"?
Or how do you handle the connection between the two databases (users and data)?
August 12, 2014 at 8:46 am
Please bore patience I am trying my best to understand.
initially I was confuse with the difference between a username and a loginname thought they were the same.
Trying to understand I created this query to see who the users are
Use DB
SELECT SID, NAME FROM dbo.sysusers
XXXXXXOOOOOOX public
OOOOXXXXXOOOO dbo
I thought the user would be the actual persons that supposed to use the data.
Anyway I copied and check the SID in the Local Machine and the one on the Network Machine and they are the same.
Viewing 15 posts - 1 through 14 (of 14 total)
You must be logged in to reply to this topic. Login to reply