senzacionale
senzacionale

Reputation: 20916

nhibernate Antlr.Runtime.NoViableAltException

return NHibernateSession.CreateQuery(@"TRUNCATE TABLE dbo.Exceptions").ExecuteUpdate();

Exception of type 'Antlr.Runtime.NoViableAltException' was thrown. [TRUNCATE TABLE Exceptions] Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: NHibernate.Hql.Ast.ANTLR.QuerySyntaxException: Exception of type 'Antlr.Runtime.NoViableAltException' was thrown. [TRUNCATE TABLE Exceptions]

Source Error:

any idea why?

Upvotes: 5

Views: 10590

Answers (1)

Diego Mijelshon
Diego Mijelshon

Reputation: 52735

TRUNCATE TABLE is not a valid HQL statement.

Use CreateSQLQuery instead of CreateQuery to execute SQL statements.

Upvotes: 20

Related Questions