(int) faultsGroup is 0 or 1 but i always get this error: Column 'FaultGroup' cannot be null
Does anyone tell me why? Syntax looks ok.
MySqlCommand cmdAdd = new MySqlCommand("INSERT INTO Faults (" +
" FaultGroup, Text, Date, IP" +
") VALUES (" +
" @FaultGroup, @Text, @Date, @IP" +
")", conn);
MySqlParameter paramFaultGroup = new MySqlParameter("@FaultGroup", MySqlDbType.Int32);
FaultsGroup faultsGroup = (FaultsGroup) Enum.Parse(typeof (FaultsGroup), myFault.FaultGroup);
paramFaultGroup.Value = (int) faultsGroup;
cmdAdd.Parameters.Add(paramFaultGroup);
cmdAdd.ExecuteNonQuery();
See Question&Answers more detail:os