Page 1 of 1

Invalid precision value

Posted: Tue 06 Jul 2010 12:46
by oz8hp
I have the following code that runs very fine on MySQL but when I try on Access I get an error saying:
[Microsoft][ODBC Microsoft Access Driver]Invalid precision value


procedure ErrorWriteDB(Const aText : String);
var
Query: TUniQuery;
begin
if aText = '' then
Exit;
Query := TUniQuery.Create(Nil);
Query.Connection := frmDBConn.conDBserver;
try
Query.SQL.Clear;
Query.SQL.Add('INSERT INTO ' + TableLogError);
Query.SQL.Add('(fldError_Time, fldError_Computer, fldError_Software, fldError_Text)');
Query.SQL.Add('values (:fldError_Time, :fldError_Computer, :fldError_Software, :fldError_Text)');
try
begin
Query.ParamByName('fldError_Time').AsDateTime := Now;
Query.ParamByName('fldError_Computer').AsString := Network.ComputerName;
Query.ParamByName('fldError_Software').AsString := conProgram_Name + ' v ' + Exe.Version + ' build ' + Exe.Build;
Query.ParamByName('fldError_Text').AsString := aText;
Query.Execute;
end;
except
on E:Exception do
Logfile.Error('Errorlog: ' + E.Message);
end;
finally
Query.UnPrepare;
Query.Free;
Application.ProcessMessages;
end;
end;

Any input to what is wrong here?

Posted: Wed 07 Jul 2010 14:11
by bork
Hello

To reproduce your issue I need the DDL script for creating the table where you are inserting data. Also I need the values of the Network.ComputerName, conProgram_Name, Exe.Version, Exe.Build, aText variables.

Posted: Thu 08 Jul 2010 12:55
by oz8hp
I think I have narrowed the problem down to the fact that Access can only handle 255 chars i text field.

But I am not quite sure yet.

Posted: Fri 09 Jul 2010 14:16
by bork
Yes, Access database doesn't allow to create text fields with size more then 255 chars. You can use the Memo data type to store large data in the text format.

Posted: Mon 12 Jul 2010 08:01
by oz8hp
Of course!

In Denmark we often say 'I didn't see the forrest because of all the trees' :D

TNX