I am trying to insert NULL value into a column type 'int'. I am using the following function but still I am getting InvalidOperationException. Here is my code. Please suggest.
p.type_id value is "null".
cmd.Parameters.AddWithValue("@type_id", ToNullableInt32(p.type_id))
public static int ToNullableInt32(string s)
{
int i;
if (Int32.TryParse(s, out i)) return i;
return null;
}