I have declared a BIT field in on of MySQL tables and i want to store bit values there.
I am using C# and I am creating Parameters for other datatypes(varchar, int etc) however i don't think the bit is supported. I am defining the field Type using the MySqlType.
Code:
cmd.Parameters.Add("?IdType",MySqlType.Int);
cmd.Parameters["?IdType"].Direction = ParameterDirection.Input;
cmd.Parameters["?IdType"].Value = comp.IdType;
cmd.Parameters.Add("?Name",MySqlType.VarChar);
cmd.Parameters["?Name"].Direction = ParameterDirection.Input;
cmd.Parameters["?Name"].Value = comp.IdType;
cmd.CommandText ="INSERT Components (type_id, name, maxLoad, CurrentLoad, State) VALUES (?IdType, ?Name, ?MaxLoad, ?CurrentLoad, ) ";
State is ob Type Bit. Is there any way i could pass that value. Should I remove parameters and concatenate the values. I tried using parameters for better coding practices.
storing BIT values using parameters
Hi.
Actually, Bit is supported as well. Have a look:
Good luck
Actually, Bit is supported as well. Have a look:
Code: Select all
cmd.Parameters.Add("IdType", MySqlType.Int);
cmd.Parameters["IdType"].Direction = ParameterDirection.Input;
cmd.Parameters["IdType"].Value = comp.IdType;
cmd.Parameters.Add("Name", MySqlType.VarChar);
cmd.Parameters["Name"].Direction = ParameterDirection.Input;
cmd.Parameters["Name"].Value = comp.Name;
cmd.Parameters.Add("State", MySqlType.Bit);
cmd.Parameters["State"].Direction = ParameterDirection.Input;
cmd.Parameters["State"].Value = comp.State;
cmd.CommandText = "INSERT into Components (Type_id, Name, State) VALUES (:IdType, :Name, :State)";