cannot find database

  • 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.

  • 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[/url]
    How to post performance related questions[/url]
    Links for Tally Table [/url] , Cross Tabs [/url] and Dynamic Cross Tabs [/url], Delimited Split Function[/url]

  • 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]

  • 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[/url]
    How to post performance related questions[/url]
    Links for Tally Table [/url] , Cross Tabs [/url] and Dynamic Cross Tabs [/url], Delimited Split Function[/url]

  • thanks

  • 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[/url]
    How to post performance related questions[/url]
    Links for Tally Table [/url] , Cross Tabs [/url] and Dynamic Cross Tabs [/url], Delimited Split Function[/url]

  • 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

  • ALTER USER UserName WITH LOGIN = LoginName

    I am sorry I could not get it to work.

    A little more explanation please.

  • 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) A socialist is someone who will give you the shirt off *someone else's* back.

  • 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

  • It looks like you have already the logins there, since the failure is "could not open database"

    If not, do as Scott suggested.

  • 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.

  • 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)?



    Lutz
    A pessimist is an optimist with experience.

    How to get fast answers to your question[/url]
    How to post performance related questions[/url]
    Links for Tally Table [/url] , Cross Tabs [/url] and Dynamic Cross Tabs [/url], Delimited Split Function[/url]

  • 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