Can I query from two databases if my web application is connected to one database?

I have a local database, DB1, that I created and is connected to my web application. My web application takes in stored procedures from DB1 and queries them. My application connects to SQL Server using my Windows Authentication account.

I have access to another database, DB2, on a different server that I have read only access to using the same windows account. Can I still query from DB2 if my application is only connected to DB1?

When I execute stored procedures in DB1 that also query stuff from DB2 it works on SQL Server Management Studio but I get an error when I try to do it on my application.