erro com campos Double Precision
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
-----------------------
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
Curtidas 0
Respostas
Adilsond
16/02/2004
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)
GOSTEI 0
Adilsond
16/02/2004
[quote=´AdilsonD´]
Altere a função acima por esta:
[/code]
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;
GOSTEI 0
Gustavolange
16/02/2004
[quote:faf0afea71=´AdilsonD´]
Altere a função acima por esta:
[/code]
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;
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;
Deu ´Range Check Error ´
qq eu fasso?
GOSTEI 0
Adilsond
16/02/2004
Desculpe-me pela falha. Mude:
for I := 0 to Length(Value) do
por
for I := 1 to Length(Value) do
for I := 0 to Length(Value) do
por
for I := 1 to Length(Value) do
GOSTEI 0
Gustavolange
16/02/2004
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 !!!
GOSTEI 0
Gustavolange
16/02/2004
Funcionou perfeitamente, muito obrigado pela ajuda Adilson !
GOSTEI 0