0

I'm tracking down an nHibernate problem. Exception thrown: 'NHibernate.Exceptions.GenericADOException' in NHibernate.dll is all it is telling me. I have show_sql set to true. So I thought I would try the sql from nHibernate manually in in SQL Server Management Studio. I added the DECLARE statements. Now I get this error: `Incorrect syntax near '@p0'' when executing on the last line. What am I doing wrong?

DECLARE @p0 VARCHAR(50);  
DECLARE @p1 INT;  
DECLARE @p2 DATETIME;  
DECLARE @p3 INT;  
DECLARE @p4 VARCHAR(10);  
DECLARE @p5 VARCHAR(50);  
DECLARE @p6 VARCHAR(80);  
DECLARE @p7 DECIMAL(11,2);  
DECLARE @p8 DATETIME;  
DECLARE @p9 VARCHAR(80);  
DECLARE @p10 INT;  
DECLARE @p11 VARCHAR(50);  

INSERT INTO MMDAML.dbo.tblMyProjectTable   
(Name, Size, UploadDate, RefId, RefType, Type, Alias, Amount, Date, Number, Stage, Caption) VALUES   
(@p0, @p1, @p2, @p3, @p4, @p5, @p6, @p7, @p8, @p9, @p10, @p11);   
select SCOPE_IDENTITY();  
@p0 = 'Project317.png' [Type: String (4000)], @p1 = 77756 [Type: Int32 (0)], @p2 = 4/14/2017 10:51:54 AM [Type: DateTime (0)], @p3 = 317 [Type: Int32 (0)], @p4 = 'Project' [Type: String (4000)], @p5 = 'Invoice' [Type: String (4000)], @p6 = 'Contract.png' [Type: String (4000)], @p7 = 4455 [Type: Decimal (0)], @p8 = 4/14/2017 10:51:23 AM [Type: DateTime (0)], @p9 = '987987' [Type: String (4000)], @p10 = 0 [Type: Int32 (0)], @p11 = NULL [Type: String (4000)]

1 Answer 1

1

; is a symbol for separating the batch, you have to add SET or another SELECT keyword before @p0 to make it a complete statement. For example,

select SCOPE_IDENTITY();  
SET @p0 = 'Project317.png'...

OR

select SCOPE_IDENTITY();  
SELECT @p0 = 'Project317.png'...
Sign up to request clarification or add additional context in comments.

1 Comment

That gets me most of the way there. I also had to remove the [Type: *] and put the date parameter values in quotes and also move the SET to before the INSERT.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.