SQL Server Error: "Cannot use empty object or column names"
I am getting the following error:
Cannot use empty object or column names. Use a single space if necessary.
Msg 1038, Level 15, State 3, Line 1
and the request command looks like this:
SELECT TOP 100 PERCENT
[].[cms_page].[pa_id], [].[cms_page].[pa_key],
[].[cms_page].[pa_title], [].[cms_page].[pa_keywords],
[].[cms_page].[pa_description], [].[cms_page].[pa_header],
[].[cms_page].[pa_created], [].[cms_page].[pa_modified],
[].[cms_page].[pa_language] FROM [cms_page]
WHERE
[cms_page].[pa_key] = @pa_key0
ORDER BY
[pa_id] ASC;
It's strange. Why is this happening? I am using SubSonic 2.1.
ConnectionString:
<add name="OCDB" connectionString="Network Library=DBMSSOCN;Data Source=127.0.0.1,1433;Initial Catalog=test_db;User ID=test;Password=testpwd"/>
Edit: Well, the solution was simply to create and rebuild the data access layer and I was good to go.
I'm not familiar with SubSonic, but have you tried a simpler query to check if your syntax is correct? Does this query even work in SQL Server (Management Studio / Query Analyzer)?
Just looking at this from a SQL Server perspective, you are using too many parentheses. If I were writing this query in SQL Server, it would be similar to what I wrote below. I'm not sure about the @ pa_key0 variable, is this part of the query a stored procedure or is SunSonic replacing this variable when running the query?
SELECT
pa_id,
pa_key,
pa_title,
pa_keywords,
pa_description,
pa_header,
pa_created,
pa_modified,
pa_language
FROM
cms_page
WHERE
pa_key = @pa_key0
ORDER BY
pa_id ASC;
a source to share
I think you need to set the schema for Subsonic. This thread seems to have some information:
Subsonic - How to use SQL schema name / owner as part of namespace?
a source to share