Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Why I'm getting an error in this simple code?
Message
 
 
To
All
General information
Forum:
C#
Category:
ADO.NET
Title:
Why I'm getting an error in this simple code?
Miscellaneous
Thread ID:
01652124
Message ID:
01652124
Views:
52
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.
If it's not broken, fix it until it is.


My Blog
Next
Reply
Map
View

Click here to load this message in the networking platform