简体   繁体   中英

Procedure or function has too many arguments specified in my stored procedure

I have this stored procedure and when I call from my c# code, I get the error and I don't know what is the problem.

Stored procedure

ALTER procedure [dbo].[modProducto]    

Store Procedure    
@id integer,    
@descripcion varchar(100),    
@tipoproducto integer,  
@existencia integer,  
@precio money  
AS  
 update producto  
set descripcion = @descripcion, idtipoproducto = @tipoproducto, existencia = @existencia, precio = @precio  
where idproducto = @id  
select 'Producto modificado correctamente'  

C# Code

MessageBox.Show(cx.ejecutarOtro("modProducto " +    
                                txtProducto.Text + ",'" +  
                                txtDescripcion.Text + "'," +  
                                (comboProducto.SelectedIndex + 1) + "," +  
                                numericUpDownExistencia.Text + "," +  
                                txtPrecioProducto.Text  
                               ));  
  • cx.ejecutarotro is an method that execute the SQL query.
  • txtProducto , txtDescripcion and txtPrecioProducto are textboxes.
  • Numericupdownexistencia is a NumericUpDown box.
  • comboProducto is a dropdown list.

Thanks in advance.

The problem is probably i18n formatting of numbers - commas vs periods. The answer is: parse the inputs properly, and use parameters. Never. Never. Never concatenate user input into SQL. Did I mention never?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM