Error saving data from a Radiogroup

Asked

Viewed 111 times

1

I’m having a problem saving the information I select in one RadioGroup in the database, after making the change that was suggested in this question the error of trying to add something in the column Active stopped, but in some cases the following error is occurring:

inserir a descrição da imagem aqui

I’m doing the Insert as follows:

begin
    sdsSuprimentoCadastro.Close;
    sdsSuprimentoCadastro.ParamByName('SUPRIMENTO').AsString := cdsSuprimentoSuprimento.AsString;
    sdsSuprimentoCadastro.Open;
    if not sdsSuprimentoCadastro.IsEmpty then
       raise  Exception.Create('Cadastro para Suprimento já incluído');
    cdsSuprimentoCodigo.AsInteger := dmDatabase.NextID('SUPRIMENTO');
      dmDatabase.SQLConnection.Execute('INSERT INTO SUPRIMENTO (CODIGO, SUPRIMENTO, CAPACIDADE, '+
       'CODIGOTIPOSUPRIMENTO, ESTOQUEMINIMO, QUANTIDADEML, PARTNUMBER, STATUS, DESCRICAO) VALUES ('+ cdsSuprimentoCodigo.AsString+','''+
       cdsSuprimentoSuprimento.AsString+''','+
       cdsSuprimentoCapacidade.AsString + ',' + cdsSuprimentoCODIGOTIPOSUPRIMENTO.AsString + ',' +
       cdsSuprimentoEstoqueMinimo.AsString +','''+cdsSuprimentoQuantidadeML.AsString +
       ''','''+cdsSuprimentoPartNumber.AsString+ ''','''+QuotedStr(cdsSuprimentostatus.AsString)+ ''','''+cdsSuprimentoDESCRICAO.AsString+''')', nil);
  end

Man update this way:

else
    dmDatabase.SQLConnection.Execute('UPDATE Suprimento SET SUPRIMENTO = '''+cdsSuprimentoSuprimento.AsString+
        ''', CAPACIDADE = '''+ cdsSuprimentoCapacidade.AsString +
        ''', CODIGOTIPOSUPRIMENTO = '+ cdsSuprimentoCODIGOTIPOSUPRIMENTO.AsString +
        ', QUANTIDADEML = '''+ cdsSuprimentoQuantidadeML.AsString +
        ''', PARTNUMBER = '''+ cdsSuprimentoPartNumber.AsString +
        ''', DESCRICAO = '''+ cdsSuprimentoDESCRICAO.AsString +
        ''', STATUS = '''+ QuotedStr(cdsSuprimentostatus.AsString)+
        ''', ESTOQUEMINIMO = '+ cdsSuprimentoEstoqueMinimo.AsString +
        ' WHERE CODIGO = '+cdsSuprimentoCodigo.AsString, nil);
  frmCadSuprimento.iCodigo := cdsSuprimentoCodigo.AsInteger;
  cdsSuprimento.Close;
  sdsSuprimento.CommandText := 'select * from Suprimento where codigo = 0';
  cdsSuprimento.Open;

table is configured like this:

inserir a descrição da imagem aqui If you have any idea what might be causing such a mistake, I’d appreciate it.

1 answer

2


I see you have a column DESCRICAO right on top of the status, she also needs the QuotedStr

Thus remaining

var update: string;
begin
  update =
        ' UPDATE Suprimento ' +
        ' SET SUPRIMENTO = ' + QuotedStr(cdsSuprimentoSuprimento.AsString) +
        '   , CAPACIDADE = '+ cdsSuprimentoCapacidade.AsString +
        '   , CODIGOTIPOSUPRIMENTO = '+ cdsSuprimentoCODIGOTIPOSUPRIMENTO.AsString +
        '   , QUANTIDADEML = '+ QuotedStr(cdsSuprimentoQuantidadeML.AsString) +
        '   , PARTNUMBER = '+ QuotedStr(cdsSuprimentoPartNumber.AsString) +
        '   , DESCRICAO = '+ QuotedStr(cdsSuprimentoDESCRICAO.AsString) +
        '   , STATUS = '+ QuotedStr(cdsSuprimentostatus.AsString)+
        '   , ESTOQUEMINIMO = '+ cdsSuprimentoEstoqueMinimo.AsString +
        ' WHERE CODIGO = '+cdsSuprimentoCodigo.AsString;

  dmDatabase.SQLConnection.Execute(update, nil);
end;

Whenever I have a field Varchar seek to use the QuotedStr.

  • I made this edition in my Update and the error is now in the description, it shows the same error window only now it shows me what is in the description field Syntax error at or near "**o que esta no campo descricao**"

  • Share the create statement from your table please.

  • I have it in Postgresql only, could it be the image of how the table is configured? With the columns, etc.

  • Columns and data type

  • I edited the question with the image of how the Database is configured

  • Edited response

  • Thanks for your help @Pablo Vargas

Show 2 more comments

Browser other questions tagged

You are not signed in. Login or sign up in order to post.