Board index » delphi » string conversion err

string conversion err


2006-01-13 07:53:09 AM
delphi95
This snip works as expected in IBConsole
UPDATE MYTABLE SET MYINTFIELD=0
But fails in Delphi when the string is built in code and used in an TIBSql
EIBInterBaseError with message: conversion error from string "0"
Thanks - and thanks also for the replies to previous posts.
 
 

Re:string conversion err

Quin writes:
Quote
This snip works as expected in IBConsole

UPDATE MYTABLE SET MYINTFIELD=0

But fails in Delphi when the string is built in code and used in an
TIBSql

EIBInterBaseError with message: conversion error from string "0"

Thanks - and thanks also for the replies to previous posts.
Your code is building the string incorrectly. If you need help
determining the cause post the code.
--
Bill Todd (TeamB)
 

Re:string conversion err

procedure qSetFieldStr( stable, sField, sNewVal, sWhere : string );
begin
IBQuery1 := TIBQuery.Create( nil );
try
with IBQuery1 do
begin
Database := FMain.IBDatabase1;
TransAction := FMain.IBTransaction1;
SQL.Text := 'UPDATE ' + stable + ' SET ' + sField + '=' + sNewVal;
if ( sWhere <>'' ) then
SQL.Add( 'WHERE ' + sWhere );
try
Open;
except
ShowMessage( SQL.Text );
end;
Close;
end;
finally
IBQuery1.Free;
end;
end;
 

Re:string conversion err

Quin writes:
Quote

procedure qSetFieldStr( stable, sField, sNewVal, sWhere : string );
begin
IBQuery1 := TIBQuery.Create( nil );
try
with IBQuery1 do
begin
Database := FMain.IBDatabase1;
TransAction := FMain.IBTransaction1;
SQL.Text := 'UPDATE ' + stable + ' SET ' + sField + '=' +
sNewVal; if ( sWhere <>'' ) then
SQL.Add( 'WHERE ' + sWhere );
try
Open;
except
ShowMessage( SQL.Text );
end;
Close;
end;
finally
IBQuery1.Free;
end;
end;
What is the value of SQL.Text in the de{*word*81} after the values have
been assigned?
--
Bill Todd (TeamB)
 

Re:string conversion err

Thanks Wayne. I knew there was something wrong and I just could not see
it. :(
--
Bill Todd (TeamB)
 

Re:string conversion err

Quin writes:
Quote
if ( sWhere <>'' ) then
SQL.Add( 'WHERE ' + sWhere );
This is going to leave no space between the last value and 'WHERE'. Add a
space here.
--
Wayne Niddery - Logic Fundamentals, Inc. (www.logicfundamentals.com)
RADBooks: www.logicfundamentals.com/RADBooks.html
"Reality is that which, when you stop believing in it, doesn't go
away." ?Philip K.{*word*106}
 

Re:string conversion err

Użytkownik "Bill Todd" <XXXX@XXXXX.COM>napisa?w wiadomości
Quote
Thanks Wayne. I knew there was something wrong and I just could not see
it. :(

--
Bill Todd (TeamB)
But i see this :-)
You try open "update" query - you must use Execute not Open.
Karol Bieniaszewski