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

html - Sizing a high-res image (~8MB) to display entirely in a small div (circular, diameter 100px) -

java - IntelliJ - No such instance method -

identifier - Is it possible for an html5 document to have two ids? -