简体   繁体   中英

SQL LocalDB Login issue

I have a website that has a DB and I have copied a backup of this DB to my local HD and can login with my windows credentials and see all the data etc.

However when I run the site on my local machine connecting to LocalDB the connection works but as the user is not the correct one as detailed in the connection string for the live site it won't work.

Is there a way to connect to LocalDB with a specified user?

Ok so the issue was that when I was connecting to LocalDB it only connects as 'dbo' and not the user that my Live SQL Server is using.

So to solve the issue I changed all the table owners in my LocalDB instance to 'dbo' and thus solved the problem for local builds and testing and it still works for the Live version as well.

If you need to do this then the following command can be used to changed a Table owner:

EXEC sp_changeobjectowner 'DBAdmin.webpages_UsersInRoles', 'dbo'

If you want to check and see who the table owner is then use:

SELECT s.name
  FROM sys.schemas AS s
  INNER JOIN sys.tables AS t
  ON s.[schema_id] = t.[schema_id]
  WHERE t.name = N'webpages_Membership';

After banging my head on this one for a few days I hope it helps someone...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM