cmd = new SqlCommand("select productid from ProductDetails where productname='" + ddlproductid.SelectedItem.ToString() + "'", con); dr = cmd.ExecuteReader(); if (dr.Read()) { proid = dr[0].ToString(); } dr.Close(); cmd.Dispose(); I had a coloumn to insert SqlParameter ProductID = new SqlParameter("ProductID", int.Parse(proid.ToString()));
The Question is: how to set the int.Parse(proid.ToString()) value as a NULL while insertion. the db datatype is integer if i pass the value to this parameter proid.ToString() its working in some cases i dosen't pass any values it throws me the conversionerror instead of that must be set as a NULL in DB
int? proid=null; SqlParameter ProductID = new SqlParameter("ProductID",proid);
SqlParameter ProductID = new SqlParameter("ProductID", Convert.ToInt32(proid));
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)