Do you know If the table "templates" has the schema owner as "dbo" or It is something else. Can you execute the following query and see If you find the table?
SELECT * FROM Unit.dbo.templates.
If you don't find the table, you should use the the following command to find out the schema owner:-
Use [Unit]
Go
sp_help templates
In the below example, the schema owner is dbo. When you execute yours, you would see some other schema owner (e.g xyz). Use that schema owner.
SELECT * FROM Unit.xyz.template
If you are still not able to find the table, It sounds like the default database for the query from the application is set to the database where the table "tenplate" does not exist. Can you try using a different form of connection string. "myUsername" in the below connection string should have same required privileges to both DatabaseA And DatabaseB:-
Server=myServerAddress;Database=myDataBase;User Id=myUsername;
Password=myPassword;
Example :-
Server=localDBv11.0;Database=DataBaseA;User Id=UserA;Password=UserAPassword;
Create a database user named "UserA" and have appropriate access to both DatabaseA and DatabaseB.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…