SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


cannot find database


cannot find database

Author
Message
earlcools
earlcools
Forum Newbie
Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)

Group: General Forum Members
Points: 6 Visits: 16
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.
LutzM
LutzM
SSChampion
SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)

Group: General Forum Members
Points: 10403 Visits: 13559
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....



Lutz
A pessimist is an optimist with experience.

How to get fast answers to your question
How to post performance related questions
Links for Tally Table , Cross Tabs and Dynamic Cross Tabs , Delimited Split Function
earlcools
earlcools
Forum Newbie
Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)

Group: General Forum Members
Points: 6 Visits: 16
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]
LutzM
LutzM
SSChampion
SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)

Group: General Forum Members
Points: 10403 Visits: 13559
earlcools (8/8/2014)
both databases has the same name

the 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!!!!



Lutz
A pessimist is an optimist with experience.

How to get fast answers to your question
How to post performance related questions
Links for Tally Table , Cross Tabs and Dynamic Cross Tabs , Delimited Split Function
earlcools
earlcools
Forum Newbie
Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)

Group: General Forum Members
Points: 6 Visits: 16
thanks
LutzM
LutzM
SSChampion
SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)

Group: General Forum Members
Points: 10403 Visits: 13559
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.



Lutz
A pessimist is an optimist with experience.

How to get fast answers to your question
How to post performance related questions
Links for Tally Table , Cross Tabs and Dynamic Cross Tabs , Delimited Split Function
arnipetursson
arnipetursson
Mr or Mrs. 500
Mr or Mrs. 500 (537 reputation)Mr or Mrs. 500 (537 reputation)Mr or Mrs. 500 (537 reputation)Mr or Mrs. 500 (537 reputation)Mr or Mrs. 500 (537 reputation)Mr or Mrs. 500 (537 reputation)Mr or Mrs. 500 (537 reputation)Mr or Mrs. 500 (537 reputation)

Group: General Forum Members
Points: 537 Visits: 1019
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
arnipetursson
arnipetursson
Mr or Mrs. 500
Mr or Mrs. 500 (537 reputation)Mr or Mrs. 500 (537 reputation)Mr or Mrs. 500 (537 reputation)Mr or Mrs. 500 (537 reputation)Mr or Mrs. 500 (537 reputation)Mr or Mrs. 500 (537 reputation)Mr or Mrs. 500 (537 reputation)Mr or Mrs. 500 (537 reputation)

Group: General Forum Members
Points: 537 Visits: 1019
Her is a nice background on the issue;
http://www.toadworld.com/platforms/sql-server/b/weblog/archive/2013/10/09/i-ve-refreshed-a-test-database-from-prod-but-now-the-users-can-t-access-it.aspx
earlcools
earlcools
Forum Newbie
Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)

Group: General Forum Members
Points: 6 Visits: 16
ALTER USER UserName WITH LOGIN = LoginName

I am sorry I could not get it to work.

A little more explanation please.
ScottPletcher
ScottPletcher
SSCertifiable
SSCertifiable (8K reputation)SSCertifiable (8K reputation)SSCertifiable (8K reputation)SSCertifiable (8K reputation)SSCertifiable (8K reputation)SSCertifiable (8K reputation)SSCertifiable (8K reputation)SSCertifiable (8K reputation)

Group: General Forum Members
Points: 7959 Visits: 7160
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)[size=2]Prosecutor James Blackburn, in closing argument in the Fatal Vision murders trial: If in the future, you should cry a tear, cry one for them [the murder victims]. If in the future, you should say a prayer, say one for them. And if in the future, you should light a candle, light one for them.[/size]
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search