I am trying to insert text (the content of a mail) to a memo field in MS Access but I get a [Microsoft][ODBC Microsoft Access Driver]Invalid precision value
I simply can't identify other problems than the text might be to to - what is the limit in UniDAC?
The code:
procedure TfrmTest.Button1Click(Sender: TObject);
var
Query: TUniQuery;
begin
Query := frmUniConn.CreateQuery;
try
Query.SQL.Clear;
Query.SQL.Add('INSERT INTO tbllogbook');
Query.SQL.Add(' ( ');
Query.SQL.Add(' fldlog_guid');
Query.SQL.Add(' ,fldlog_text');
Query.SQL.Add(' ) values ( ');
Query.SQL.Add(' :fldlog_guid');
Query.SQL.Add(' ,:fldlog_text');
Query.SQL.Add(' ) ');
Query.ParamByName('fldlog_guid').AsString := GuidCreate;
Query.ParamByName('fldlog_text').AsString := Memo1.Text;
Query.Execute;
finally
Query.Free;
end;
end;
frmUniConn is a datamodule where I create the connection to database and the Query
[Microsoft][ODBC Microsoft Access Driver]Invalid precision value
Re: [Microsoft][ODBC Microsoft Access Driver]Invalid precision value
Figured that one out - had to change code to
procedure TfrmTest.Button1Click(Sender: TObject);
var
Query: TUniQuery;
Stream: TStringStream;
begin
Stream := TStringStream.Create('');
Query := frmUniConn.CreateQuery;
Stream.WriteString(Memo1.Text);
try
Query.SQL.Clear;
Query.SQL.Add('INSERT INTO tbllogbook');
Query.SQL.Add(' ( ');
Query.SQL.Add(' fldlog_guid');
Query.SQL.Add(' ,fldlog_text');
Query.SQL.Add(' ) values ( ');
Query.SQL.Add(' :fldlog_guid');
Query.SQL.Add(' ,:fldlog_text');
Query.SQL.Add(' ) ');
Query.ParamByName('fldlog_guid').AsString := GuidCreate;
Query.ParamByName('fldlog_text').LoadFromStream(Stream, ftMemo);
Query.Execute;
finally
Query.Free;
Stream.Free;
end;
end;
Now I just need testing on MySQL, MS SQL and SQLite
procedure TfrmTest.Button1Click(Sender: TObject);
var
Query: TUniQuery;
Stream: TStringStream;
begin
Stream := TStringStream.Create('');
Query := frmUniConn.CreateQuery;
Stream.WriteString(Memo1.Text);
try
Query.SQL.Clear;
Query.SQL.Add('INSERT INTO tbllogbook');
Query.SQL.Add(' ( ');
Query.SQL.Add(' fldlog_guid');
Query.SQL.Add(' ,fldlog_text');
Query.SQL.Add(' ) values ( ');
Query.SQL.Add(' :fldlog_guid');
Query.SQL.Add(' ,:fldlog_text');
Query.SQL.Add(' ) ');
Query.ParamByName('fldlog_guid').AsString := GuidCreate;
Query.ParamByName('fldlog_text').LoadFromStream(Stream, ftMemo);
Query.Execute;
finally
Query.Free;
Stream.Free;
end;
end;
Now I just need testing on MySQL, MS SQL and SQLite
Re: [Microsoft][ODBC Microsoft Access Driver]Invalid precision value
Hello,
We cannot reproduce the problem on the latest UniDAC 5.2.7 version and MS Access 2013: data is inserted correctly, please try to reproduce the problem on the latest UniDAC version and let us know the result.
We cannot reproduce the problem on the latest UniDAC 5.2.7 version and MS Access 2013: data is inserted correctly, please try to reproduce the problem on the latest UniDAC version and let us know the result.
Re: [Microsoft][ODBC Microsoft Access Driver]Invalid precision value
The problem only exists if the text is > 255 chars
I have no access to the new versions of UniDAC. The program I am altering is an old one I made for a company I used to work for. I am working on their computer with the old Delphi & UniDAC that hasn't been updated for quite some time.
But the solution I have described solves the issue for me with texts > 255 chars
I have no access to the new versions of UniDAC. The program I am altering is an old one I made for a company I used to work for. I am working on their computer with the old Delphi & UniDAC that hasn't been updated for quite some time.
But the solution I have described solves the issue for me with texts > 255 chars
Re: [Microsoft][ODBC Microsoft Access Driver]Invalid precision value
To solve the problem, you should specify explicitly the parameter type, .i.e:
Code: Select all
....
Query.ParamByName('fldlog_text').DataType := ftMemo;
Query.ParamByName('fldlog_text').AsString := Memo1.Text;
....Re: [Microsoft][ODBC Microsoft Access Driver]Invalid precision value
OK - I will try that.
TNX
TNX