This code will insert Null value in Int data type column
C#
protected void Save(object sender, EventArgs e)
{
int no = 0;
string constr = ConfigurationManager.ConnectionStrings["Constr"].ConnectionString;
using (SqlConnection con = new SqlConnection(constr))
{
string query = "insert into tblCheckIn values (@Number)";
using (SqlCommand cmd = new SqlCommand(query))
{
cmd.Connection = con;
if (no == 0)
{
cmd.Parameters.AddWithValue("@Number", DBNull.Value);
}
else
{
cmd.Parameters.AddWithValue("@Number", no);
}
con.Open();
cmd.ExecuteNonQuery();
con.Close();
}
}
}
SQL