sturdytree
sturdytree

Reputation: 859

SQL Server compact 4.0 - '[ ]' not working for keywords?

I have a column name [End] set up in SQL Server compact 4.0, and a mapping in NHibernate (v3.3)

<property name="End" column="[End]" not-null="true" />

However, I get the error:

InnerException: System.Data.SqlServerCe.SqlCeException
   HResult=-2147467259
   Message=The column name is not valid. [ Node name (if any) = amendedday0_,Column name = End ]
   Source=SQL Server Compact ADO.NET Data Provider
   ErrorCode=-2147467259
   NativeError=25503

The NHibernate generated SQL is:

[SQL: SELECT table0_.[End] as column3_8_0_,]

As far as I can tell, this means the SQL driver cannot find a column name [End] in the database? However, MSDN guidance is to use [] or "" around keywords, so [End] should be found?

Please could you help point me in the right direction to fix this.

PS I know I can change to not use a keyword, but am interested why the above does not work

Upvotes: 0

Views: 220

Answers (1)

sturdytree
sturdytree

Reputation: 859

OK, silly mistake, I used [End] in the actual column definition when setting up the table, should just use End

Upvotes: 0

Related Questions