Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Why I'm getting an error in this simple code?
Message
 
 
À
Tous
Information générale
Forum:
C#
Catégorie:
ADO.NET
Titre:
Why I'm getting an error in this simple code?
Divers
Thread ID:
01652124
Message ID:
01652124
Vues:
53
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
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform