Board index » delphi » dbcheckbox with mysql

dbcheckbox with mysql

I have dbcjeckbox and a databse mysql. When i rely together with a
tyniint(1), that doesn't work? How i do this?

Thanks

 

Re:dbcheckbox with mysql


Quote
pierreprovenc...@hotmail.com (Pierre Provencher) wrote in message <news:6ff94ed4.0210241816.1cce78c7@posting.google.com>...
> I have dbcjeckbox and a databse mysql. When i rely together with a
> tyniint(1), that doesn't work? How i do this?

> Thanks

Pierre,

with the dbcheckbox, in the object inspector
On the ValueChecked property := 1;
On the ValueUnchecked property := -1;
You MUST leave the DefaultExpression of the field on your Query or
Table blank - YES;NO or QUI;NON gives a grey checkbox.

Check out how I created the field in this procedure:

procedure TdmData.CreatePlantTable(Sender: TObject);
begin
  With qPlant do
  Try
    Active := False;
    Sql.Clear;
    Sql.Add('DROP TABLE IF EXISTS PLANT');
    ExecSql;
    transPlant.Commit;
    Sql.Clear;
    Sql.Add('CREATE TABLE PLANT (PLANTID int(10) unsigned NOT NULL ' +
        'DEFAULT ''0'' auto_increment,');
    Sql.Add(' COMMONNAME varchar(40),');
    Sql.Add(' BOTANICALNAME varchar(40),');
    Sql.Add(' DIRECTSUN tinyint(1) DEFAULT ''-1'',');
    Sql.Add(' BRIGHTLIGHT tinyint(1) DEFAULT ''-1'',');
    Sql.Add(' MEDIUMLIGHT tinyint(1) DEFAULT ''-1'',');
    Sql.Add(' LOWLIGHT tinyint(1) DEFAULT ''-1'',');
    Sql.Add(' EVENMOIST tinyint(1) DEFAULT ''-1'',');
    Sql.Add(' SLIGHTMOIST tinyint(1) DEFAULT ''-1'',');
    Sql.Add(' DRYOUT tinyint(1) DEFAULT ''-1'',');
    Sql.Add(' MIST tinyint(1) DEFAULT ''-1'',');
    Sql.Add(' FERTILIZER varchar(25),');
    Sql.Add(' PROPAGATION varchar(25),');
    Sql.Add(' PROBLEMS varchar(25),');
    Sql.Add(' DETAILS text,');
    Sql.Add(' ARCHIVED tinyint(1) DEFAULT ''-1'',');
    Sql.Add(' PRIMARY KEY(PLANTID),');
    Sql.Add(' INDEX PLANTSORT(COMMONNAME))');
    ExecSql;
    transPlant.Commit;
    Sql.Clear;
    Sql.Add('SELECT * FROM PLANT');
    Sql.Add(' WHERE ARCHIVED = ''-1''');
    Sql.Add(' ORDER BY COMMONNAME');
    Active := True;
  Except  { If an error occurs, the Table Not created tell me }
    MessageDlg('What the ??  An Error.  Plant Table NOT Created.',
        mtError, [mbOK], 0);
    Active := True;
  End;
end;

HTH

John

Other Threads