c# - UpdateCommand Parameter value always a string -
i trying update shopping cart in application using gridview , sqldatasource control, i'm trying set update command parameters can send values sql stored proc, keeps throwing exception saying can't convert nvarchar string.
given below code;
productsdatasource.updateparameters.add("description", row.cells[2].text);
it seems method not accept other string it's second argument, how can convert other values pass parameters?
i have tried this;
int productid = int.parse(row.cells[1].text);
but since second parameter has have string argument, can't insert db (complaining can't implicitly convert string!)
you can specify parameter type on markup..
<updateparameters > <asp:parameter name="paramname" dbtype="string" type="string" />
and can set value on code behind.
productsdatasource.updateparameters["paramname"].defaultvalue = "parameter value";
or can use overloads of add method without markup definition.
sqldatasource1.updateparameters.add("paramname", dbtype.string, "parameter value");
Comments
Post a Comment