pegando valores de um edit para sql
boa tarde a todos
eu gostaria de saber como fazer para pegar valores que estão em edit e incluir em um apdate ou insert into sql, ceja meu código abaixo esta dando erro
procedure TForm1.BitBtnAlterarClick(Sender: TObject);
begin
try
Transacao.TransactionID :=1;
Transacao.IsolationLevel := xilREPEATABLEREAD;
SQLConnection1.StartTransaction(Transacao);
SQLDataSet1.Close;
SQLDataSet1.CommandType := ctQuery;
SQLDataSet1.CommandText := ´update Comandos set Sintaxe = :Sint, Funcao = :Func, valor = valor +´+FloatToStr(StrToFloat(EdVlr.text)) ´+ WHERE Sintaxe = :Sint´;
SQLDataSet1.ParamByName(´Sint´).AsString := EdSintaxe.Text;
SQLDataSet1.ParamByName(´Func´).AsString := EdFuncao.Text;
// SQLDataSet1.ParamByName(´vlr´).AsCurrency := EdFuncao.Text;
SQLDataSet1.ExecSQL;
SQLConnection1.Commit(Transacao);
except
on Exc:Exception do
begin
ShowMessage(´Ocorreu um erro na tentativa de alteração do registro:´+Exc.Message);
SQLConnection1.Rollback(Transacao);
end;
end;
end;
desde já obrigado pela atenção de todos
eu gostaria de saber como fazer para pegar valores que estão em edit e incluir em um apdate ou insert into sql, ceja meu código abaixo esta dando erro
procedure TForm1.BitBtnAlterarClick(Sender: TObject);
begin
try
Transacao.TransactionID :=1;
Transacao.IsolationLevel := xilREPEATABLEREAD;
SQLConnection1.StartTransaction(Transacao);
SQLDataSet1.Close;
SQLDataSet1.CommandType := ctQuery;
SQLDataSet1.CommandText := ´update Comandos set Sintaxe = :Sint, Funcao = :Func, valor = valor +´+FloatToStr(StrToFloat(EdVlr.text)) ´+ WHERE Sintaxe = :Sint´;
SQLDataSet1.ParamByName(´Sint´).AsString := EdSintaxe.Text;
SQLDataSet1.ParamByName(´Func´).AsString := EdFuncao.Text;
// SQLDataSet1.ParamByName(´vlr´).AsCurrency := EdFuncao.Text;
SQLDataSet1.ExecSQL;
SQLConnection1.Commit(Transacao);
except
on Exc:Exception do
begin
ShowMessage(´Ocorreu um erro na tentativa de alteração do registro:´+Exc.Message);
SQLConnection1.Rollback(Transacao);
end;
end;
end;
desde já obrigado pela atenção de todos
Altenir
Curtidas 0
Respostas
Martins
05/01/2007
try Transacao.TransactionID :=1; Transacao.IsolationLevel := xilREPEATABLEREAD; SQLConnection1.StartTransaction(Transacao); SQLDataSet1.Close; SQLDataSet1.CommandType := ctQuery; SQLDataSet1.CommandText := ´update Comandos set Sintaxe = :Sint, Funcao = :Func, valor =:valor WHERE Sintaxe = :Sint´; SQLDataSet1.ParamByName(´Sint´).AsString := EdSintaxe.Text; SQLDataSet1.ParamByName(´Func´).AsString := EdFuncao.Text; SQLDataSet1.ParamByName(´valor´).AsCurrency := StrToFloat(EdVlr.Text); SQLDataSet1.ExecSQL; SQLConnection1.Commit(Transacao); except on Exc:Exception do
Tente assim, use parametros.
GOSTEI 0