Click here to Skip to main content
15,670,234 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Using Microsoft Visual Studio Community 2022 Version 17.5.3

I have two SQL database projects in my solution: Proj1 and Proj1Log. Proj1 database contains a function that retrieves information from tables of Proj1Log. The function looks like "select ... from [$(Proj1Log)].[dbo].[LogTable]".

To handle the $(Proj1Log) variable I tried to add a reference from Proj1 to Proj1Log using the "Add Database Reference" -> "Database project in current solution" and selecting the Proj1Log project with the corresponding variable.
But adding the reference failed with the following error: "Project Proj1.sqlproj contains a reference to a project which is unloaded: <path>\Proj1Log.sqlproj.".

Both projects are successfully loaded in the solution.

How can I fix the error and add reference to another database project?

Please, advise.
Thank you.

What I have tried:

1. Unload and reload one of the projects and both of them.
2. Temporary exclude the function referencing Proj1Log from the Proj1 in order to compile both projects without any error / warning.
3. Ask Google for the solution - the similar question on Stack Overflow has no answer.
Posted
Comments
Gerry Schmitz 25-Mar-23 18:18pm    
Show the rest of the "function". Maybe you have your languages mixed up.
Haifovchanin 27-Mar-23 7:56am    
This is the query in Proj1, that creates the function.
TypeId (integer) and Timestamp (timestamp) columns are defined in the Log table in Proj1Log project.

CREATE FUNCTION [dbo].[ViewErrorLog]
(
@logType int
)
RETURNS TABLE
AS
RETURN
(
select top(300)
[Id] as 'Id'
,[Time] as 'Time'
,[Application] as 'Application'
,[Text] as 'Error'
from [$(Proj1Log)].[dbo].[Log] with (nolock)
where [TypeId] <= @logType
order by [Timestamp] desc
)
mtoha 6-Apr-23 2:10am    
actually, when I am having that error, I am just skip that error. SQL DB Project sometimes buggy, and no problem with another .NET Project.
Haifovchanin 10-Apr-23 2:29am    
Thanks for an answer!
The code works correctly on real SQL DB.
Your answer is the best. :)
mtoha 10-Apr-23 9:20am    
Alright. great.. You are welcome

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900