storing BIT values using parameters

storing BIT values using parameters

Postby maxnetpromo » Sat 18 Mar 2006 12:11

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.
maxnetpromo
 
Posts: 1
Joined: Sat 18 Mar 2006 12:02

Postby Alexey » Mon 20 Mar 2006 07:19

Hi.
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)";


Good luck
Alexey
 
Posts: 2756
Joined: Mon 13 Mar 2006 07:43


Return to dotConnect for MySQL