Fórum erro com campos Double Precision #214452

16/02/2004

0

Bom Dia amigos...
Seguinte, quando eu gravo um valor com virgula no meu sistema, ele simplesmente ignora a virgula
to usando interbase 6, o campo é double precision e o código é o seguinte:


if not MySQL(dm.qryGenerica,´insert into produtos (cod,produto,preco,unMed,dtInc,prcusto,narrativa) values ´+
´(´+lblCod.caption+´,´+QuotedStr(edtProduto.text)+
//esse ta com problema
´,´+QuotedStr(edtPreco.text)+

´,´+quotedstr(cmbUnMed.text)+

´,´+quotedstr(lblDate.caption)+
//e esse também...

´,´+QuotedStr(edtPrecoCusto.text)+

´,´+quotedstr(mm.lines.text)+´)´) then

Application.messagebox(´Erro tentando gravar na tabela de Produtos...´,´Erro´,
mb_ok+mb_iconerror)

Alguém pode me ajudar?

Grato.

-----------------------
Gustavo Lange
Téc. Informática
gustavo@joscil.com.br
-----------------------


Gustavolange

Gustavolange

Responder

Posts

16/02/2004

Adilsond

function TranlateVal(Value: String): String;
var
  I: Word;
  S: String;
begin
  S := ´0´;
  for I := 0 to Length(Value) do
    begin
      if Value[I] in [´0´..´9´] then
         S := S + Value[I]
      else
         if Value[I] = ´,´ then
            S := S + ´.´;
    end;    
end;


Troque QuotedStr(edtPreco.text) por TranlateVal(edtPreco.text)


Responder

Gostei + 0

16/02/2004

Adilsond

[quote=´AdilsonD´]
function TranlateVal(Value: String): String;
var
  I: Word;
  S: String;
begin
  S := ´0´;
  for I := 0 to Length(Value) do
    begin
      if Value[I] in [´0´..´9´] then
         S := S + Value[I]
      else
         if Value[I] = ´,´ then
            S := S + ´.´;
    end;    
end;


Altere a função acima por esta:

function TranlateVal(Value: String): String;
var
  I: Word;
  S: String;
begin
  S := ´0´;
  if Length(Value) > 0 then
     begin
       for I := 0 to Length(Value) do
         begin
           if Value[I] in [´0´..´9´] then
              S := S + Value[I]
           else
              if Value[I] = ´,´ then
                 S := S + ´.´;
         end;
     end;
  Result := S;
end;
[/code]


Responder

Gostei + 0

16/02/2004

Gustavolange

[quote:faf0afea71=´AdilsonD´]
function TranlateVal(Value: String): String;
var
  I: Word;
  S: String;
begin
  S := ´0´;
  for I := 0 to Length(Value) do
    begin
      if Value[I] in [´0´..´9´] then
         S := S + Value[I]
      else
         if Value[I] = ´,´ then
            S := S + ´.´;
    end;    
end;
Altere a função acima por esta:
function TranlateVal(Value: String): String;
var
  I: Word;
  S: String;
begin
  S := ´0´;
  if Length(Value) > 0 then
     begin
       for I := 0 to Length(Value) do
         begin
           if Value[I] in [´0´..´9´] then
              S := S + Value[I]
           else
              if Value[I] = ´,´ then
                 S := S + ´.´;
         end;
     end;
  Result := S;
end;
[/code]


Deu ´Range Check Error ´
qq eu fasso?


Responder

Gostei + 0

16/02/2004

Adilsond

Desculpe-me pela falha. Mude:

for I := 0 to Length(Value) do

por

for I := 1 to Length(Value) do


Responder

Gostei + 0

16/02/2004

Gustavolange

Desculpe-me pela falha. Mude: for I := 0 to Length(Value) do por for I := 1 to Length(Value) do


Ok. Vou testar e qualque coisa volto a perguntar.
Obrigado Adilson !!!


Responder

Gostei + 0

16/02/2004

Gustavolange

Funcionou perfeitamente, muito obrigado pela ajuda Adilson !


Responder

Gostei + 0

Utilizamos cookies para fornecer uma melhor experiência para nossos usuários, consulte nossa política de privacidade.

Aceitar