Advise what to do if I made a request to the database, but did not receive the value, provided that it is there exactly, I do not know what malfunctions happen when working with the database, does it make sense to do a second call, through repeat for example 5 times, and if there is no answer anyway then shutting down with an error? That's how I make requests

class function RGetInfo.GetLoginUser(LoginUser: TLoginUser): Boolean; var FDConnection: TFDConnection; FDQuery: TFDQuery; begin FDConnection := TFDConnection.Create(nil); try with FDConnection do begin Params.Add('Database=mybd'); Params.Add('DriverID=MySQL'); Params.Add('Password=123456'); Params.Add('Server=localhost'); Params.Add('User_Name=root'); Params.Add('CharacterSet=utf8'); Params.Add('ReadTimeout=100'); Connected := True; end; FDQuery := TFDQuery.Create(nil); try FDQuery.Connection := FDConnection; try FDQuery.SQL.Clear; FDQuery.SQL.Add('SELECT * FROM `uplayers` WHERE `name` = "' + LoginUser.Name + '" LIMIT 1'); FDQuery.Open; LoginUser.pType := FDQuery.FieldByName('type').AsString; LoginUser.Pass := FDQuery.FieldByName('pass').AsString; LoginUser.PassType := FDQuery.FieldByName('passtype').AsString; LoginUser.Active := FDQuery.FieldByName('active').AsBoolean; LoginUser.Oper.Name := FDQuery.FieldByName('oper').AsString; LoginUser.Admin.Name := FDQuery.FieldByName('admin').AsString; LoginUser.SuperAdmin.Name := FDQuery.FieldByName('superadmin').AsString; FDQuery.Close; finally Result := True; end; finally FDQuery.Free; end; finally FDConnection.Free; end; end; 
  • And you do not want to give an example of what you are doing, with an example of what fields are in the database? - Shnur
  • @Shnur added a question - ArtGrek13
  • Perhaps it makes sense before the request to start a new transaction .. - vp_arth
  • one
    I made a request to the database, but did not receive the value, provided that it is exactly there And then your desire to make 5 repeat-s is akin to for(i=1,i<5,i++) {x=2?x:2;} - Akina
  • one
    If the query to the database worked without errors and the DB did not return the value, then it is not there, whatever that means - Mike

1 answer 1

As practice shows, in such cases, most often the problem is in the request itself. And repeatables won't help here. I would look at the value of FDQuery.SQL.Text and paste it into some SQL editor, such as phpMyAdmin. And on the vskidku, the problem may be in quotes. Try instead of SELECT * FROM uplayers WHERE name write SELECT * FROM [uplayers] WHERE [name]

or just SELECT * FROM uplayers WHERE name