You are viewing limited content. For full access, please sign in.

Question

Question

Custom Query is not executing store procedure with parameters

asked on February 13

 

But it work if i send the parameters as specific values.

 

0 0

Replies

replied on February 13 Show version history

Try creating your inputs and query string as variables and then execute the Query variable. Something similar to this:

DECLARE @Input1 int
DECLARE @Input2 nvarchar(75)
DECLARE @sqlCommand nvarchar(1000)
SET @Input1 = ?
SET @Input2 = ?
SET @sqlCommand = '[dbo].[Yearly_Serial_Number] @SubmissionID=' +@Input1 + ' , @CreatorUser=' + @Input2 + ';'
EXEC (@sqlCommand) 

Note that in the @sqlCommand, you may have to add the quotations around your @Input2 (after the "=" and before the ";") to make it execute properly. To include a quote(') in a nvarchar, you must "escape" it by repeating it (2 quotes in a row includes 1 quote in the nvarchar).

@CreatorUser=''' + @Input2 + ''';'

 

0 0
replied on February 13

Your syntax can't include named parameters for ODBC because does not support named parameters.

(the order of the values should match the order the procedure expects the parameters in)

0 0
replied two days ago

Dear Miruna

 

Have a nice day, sorry for the late reply cz my reply box was not working before. 

Well i have tried with your method but it failed. later on i tried with a different method and it worked, check as below.

 

 

0 0
You are not allowed to follow up in this post.

Sign in to reply to this post.