The parameterized query expects the parameter which was not supplied c# SQL -


i new in sql , c# , encountered sql error.

the parameterized query '(@pid nvarchar(4000),@desc nvarchar(4000),@cat nvarchar(4000),@p' expects parameter '@pid', not supplied.

i need help. thanks!

 public void insertrecord()     {         sqlcommand cmd = new sqlcommand("insert products values (@pid, @desc, @cat, @price, @scode)", mycon);         cmd.parameters.addwithvalue("@pid", productid);         cmd.parameters.addwithvalue("@desc", description);         cmd.parameters.addwithvalue("@cat", category);         cmd.parameters.addwithvalue("@price", price);         cmd.parameters.addwithvalue("@scode", suppliercode);//corrected "key codes"          mycon.open();         cmd.executenonquery();         mycon.close();//added these lines of codes     } 

you must check every parameters if null. if are, have pass dbnull.value.

sqlparameter pidparam = command.parameters.addwithvalue("@pidparam", productid); if (productid == null) {     pidparam.value = dbnull.value; } 

source: the parameterized query ..... expects parameter '@units', not supplied


Comments

Popular posts from this blog

php - regexp cyrillic filename not matches -

c# - OpenXML hanging while writing elements -

sql - Select Query has unexpected multiple records (MS Access) -