Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Why I'm getting an error in this simple code?
Message
From
19/06/2017 14:51:10
 
General information
Forum:
C#
Category:
ADO.NET
Miscellaneous
Thread ID:
01652124
Message ID:
01652125
Views:
75
This message has been marked as the solution to the initial question of the thread.
>Hi everybody,
>
>I can not figure out why this command complains about expecting a parameter which I'm clearly supplying. Same code works fine in SSMS. Do you see what I may be missing here?
>
>
>   using (SqlCommand sqlCommand = new SqlCommand())
>            {
>                sqlCommand.CommandType = CommandType.Text;
>                sqlCommand.CommandText = @";merge dbo.gst_actv as trgt 
>      using (select cast(pass_no as char(16)) as ref_no
>           from dbo.gst_pass
>           where pending = 1 and salespoint = @salespoint) as srce 
>          on trgt.ref_no = srce.ref_no 
>      when matched and trgt.activ_type between 100 and 199 
>      then delete; 
>
>    delete dbo.gst_pass where pending = 1 and salespoint = @salespoint;";
>                
>                sqlCommand.Parameters.Add("@salespoint", SqlDbType.Char, 6).Value = this.CurrentSalespoint;
>                database.ExecuteSqlCommand(sqlCommand, CommandExecutionType.NonQuery);
>                messageText = this.GetFormattedReturn();
>            }
>
>The error is this:
>
>The parameterized query '(@salespoint char(6));merge dbo.gst_actv as trgt
> using (' expects the parameter '@salespoint', which was not supplied.
>
>It sounds like some weird bug to me.
I get that error when the value of the parameter = null
Anyone who does not go overboard- deserves to.
Malcolm Forbes, Sr.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform