1

I get 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 query command looks like:

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;

Strange indeed. Why does this happen? I'm 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 just to simply generate and rebuild the Data Access Layer and I was good to go.

  • Can you post the code that causes the error? Does this happen for every query or just one? – Adam Cooper May 11 '09 at 09:37
  • [code]CmsPage page = new CmsPage(CmsPage.Columns.PaKey, key); page.PaLanguage = SelectedLanguage; page.Save();[/code] that's it... I'm pretty sure it's some config setting which hasn't been set. because this code works on other sites. –  May 11 '09 at 11:10
  • OK sounds like no SubSonic queries are working, is that correct? – Adam Cooper May 11 '09 at 11:21
  • @Elrinth: You can edit your own question, it's best to post the code there directly instead of a comment. – Tomalak May 11 '09 at 12:03
  • yeah actually, I think I just need to rebuild my DAL and it's good to go :) –  May 11 '09 at 13:52

4 Answers4

1

You seem to be using a 3 part name with part of it empty, i.e. '[].'

Mitch Wheat
  • 295,962
  • 43
  • 465
  • 541
0

It looks as though the query text is being constructed with an empty table schema.

Those empty [] square brackets should contain something like "dbo" to make the query syntactically valid. I don't know enough about SubSonic to give you a code sample though.

Tomalak
  • 332,285
  • 67
  • 532
  • 628
  • yes, it's very strange. I would like to know why nothing is inserted. –  May 11 '09 at 09:12
  • 1
    Show the code that generates the faulty query and someone might be able to tell you. Without any code to look at it is hard to guess. :) – Tomalak May 11 '09 at 09:38
  • The code is just standard subsonic stuff. I doubt anyone'll get much wiser by the code I just posted :) –  May 11 '09 at 11:09
0

I'm not familiar with SubSonic, but have you tried a simpler query to test if you have your syntax correct? Does this query even work in SQL Server (Management Studio / Query Analyzer)?

Just looking at this from the perspective of SQL Server, you are using way too many brackets. If I was writing that query in SQL Server, it would look more like what I wrote below. I'm not sure about the variable @pa_key0, is this query part of a stored procedure or does SunSonic replace this variable when the query is ran?

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;
jj.
  • 2,210
  • 3
  • 21
  • 22
0

I think you need to set the schema for Subsonic to use. This thread seems to have some information:

Subsonic - How to use SQL Schema / Owner name as part of the namespace?

Community
  • 1
  • 1
Adam Ruth
  • 3,575
  • 1
  • 21
  • 20