mysql_query(mysql, pChar('SELECT * FROM '+stock+' WHERE code = '+recup));
mysql_query(mysql, pChar('SELECT * FROM '+stock+' WHERE code = '+QuotedStr(recup)));
mysql_query(mysql, pChar('SELECT * FROM '+stock+' WHERE code = 1000'));
implementation CONST dbname='base'; stock='stock'; vente='vente'; {$R *.dfm}
procedure TSaisi.StringGrid1KeyPress(Sender: TObject; var Key: Char); var i:integer; user,host,pwd:string; port:integer; resultat: PMYSQL_RES; row:PMYSQL_ROW; recup:string; multiplication:currency; begin {Initialisation des variables de connection à la base de donnée} user:='root'; pwd:=''; host:='127.0.0.1'; port:=3306; {Initialisation de la connection base de donnée} MySQL := mysql_init(nil); mysql_options(mysql,MYSQL_OPT_COMPRESS,nil); {Connection base de donnée} mysql_real_connect(mysql, pChar(host), pChar(user), pChar(pwd), nil, port, nil, 0); {Selection de la base de donnée} mysql_select_db(mysql, pChar(dbname)) ; {Mise à jour automatique des cellules par code rayon} recup:=StringGrid1.Cells[1,1]; mysql_query(mysql, pChar('SELECT * FROM '+table+' WHERE code =' +recup)); resultat:=mysql_use_result(MySQL); row:=mysql_fetch_row(Resultat); StringGrid1.Cells[2,1]:= row[2]; StringGrid1.Cells[3,1]:= row[3]; StringGrid1.Cells[4,1]:= IntToStr(1); StringGrid1.Cells[5,1]:= row[6]; multiplication:= StrToFloat(StringGrid1.Cells[5,1]) * StrToFloat(StringGrid1.Cells[4,1]); StringGrid1.Cells[5,1]:= currtostrf(multiplication, fffixed, 2); {Mise à jour automatique des cellules par reference} {Calcul du montant à payer} somme := 0; for i := 1 to stringgrid1.rowcount - 1 do try somme := somme + strtocurr(Stringgrid1.cells[5,i]); except begin somme := somme + 0; end; end; remise := strtocurr(Edit5.text); edit6.text := currtostrf(somme - remise, fffixed, 2); end;
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre questionmysql_real_connect(mysql, pChar(host), pChar(user), pChar(pwd), nil, port, nil, 0);
if mysql_real_connect(mysql, pChar(host), pChar(user), pChar(pwd), nil, port, nil, 0) <> nil then...
mysql_query(mysql, pChar('SELECT * FROM '+stock+' WHERE code = ''' + recup + ''''));