how to pass sql parameter as null value in to integer data type variable ?
StockBO sBO = new StockBO();
sBO.Mode = 2;
if (ddcmpanyname.SelectedIndex != 0)
{
sBO.Client_id = Convert.ToInt16(ddcmpanyname.SelectedValue);
}
else
{
sBO.Client_id = Convert.ToInt16(DBNull.Value);//Object cannot be cast from DBNull to other types.
sBO.Client_id =DBNull.Value;//Cannot implicitly convert type
}
ds=_StockController.StockGet(sBO);
i changed the code like this it gives error like i my comment check else part
Try this,
else
{
sBO.Client_id = System.Data.SqlTypes.SqlInt32.Null;
}