Delphi & MS Access
Delphi & MS Access
(OP)
Hallo,
I have some problems with saving a long text (longer then 255 characters) into MS Access database.
When I want to save it, the error screen pups up and it contains:
[0] General SQL error.
[Microsoft][ODBC Microsoft Access Driver] Invalid descriptor index
[Microsoft][ODBC Microsoft Access Driver] Invalid precision value
The data base is MS Access 2000: field ôtestö is defined as ômemoö. I am using Delphi 6, ODBC 5.2, TQuery:
Code for saving:
procedure TaOrganizacija.Button1Click(Sender: TObject);
var
sql_niz: String;
begin
sql_niz:='INSERT INTO organizacije (test) VALUES (:test) ';
QOrg.Close;
QOrg.DatabaseName:=sys_dbalias;
QOrg.SQL.Clear;
QOrg.SQL.Add(sql_niz);
QOrg.ParamByName('test').AsString:=mOpomba.Text;
Try QOrg.ExecSQL;
Except
On E: Exception Do
begin
ShowMessage('['+inttostr(E.HelpContext)+'] '+E.Message+#13#10);
end;
End;
end;
The error occurs if I want to save in this field text, longer then 255 characters.
If I use QOrg.ParamByName('test').AsMemo:=mOpomba.Text; , the error screen pups up and it contains:
[0] General SQL error.
[Microsoft][ODBC Microsoft Access Driver] String data, right truncated (null).
If the text is shorter than there is no problem. If anyone already had similar problems, I would be thankful if you could share the solutions. Any kind of tips would be helpful.
Thanx
SaX
I have some problems with saving a long text (longer then 255 characters) into MS Access database.
When I want to save it, the error screen pups up and it contains:
[0] General SQL error.
[Microsoft][ODBC Microsoft Access Driver] Invalid descriptor index
[Microsoft][ODBC Microsoft Access Driver] Invalid precision value
The data base is MS Access 2000: field ôtestö is defined as ômemoö. I am using Delphi 6, ODBC 5.2, TQuery:
Code for saving:
procedure TaOrganizacija.Button1Click(Sender: TObject);
var
sql_niz: String;
begin
sql_niz:='INSERT INTO organizacije (test) VALUES (:test) ';
QOrg.Close;
QOrg.DatabaseName:=sys_dbalias;
QOrg.SQL.Clear;
QOrg.SQL.Add(sql_niz);
QOrg.ParamByName('test').AsString:=mOpomba.Text;
Try QOrg.ExecSQL;
Except
On E: Exception Do
begin
ShowMessage('['+inttostr(E.HelpContext)+'] '+E.Message+#13#10);
end;
End;
end;
The error occurs if I want to save in this field text, longer then 255 characters.
If I use QOrg.ParamByName('test').AsMemo:=mOpomba.Text; , the error screen pups up and it contains:
[0] General SQL error.
[Microsoft][ODBC Microsoft Access Driver] String data, right truncated (null).
If the text is shorter than there is no problem. If anyone already had similar problems, I would be thankful if you could share the solutions. Any kind of tips would be helpful.
Thanx
SaX





RE: Delphi & MS Access
RE: Delphi & MS Access
Maybe another solution?
THX
SaX
RE: Delphi & MS Access
The MVP's in these forums are doing a fantastic job.
There is also a chance that your problem is described somewhere in Delphi newsgroups/forums
Good luck,
Engin
RE: Delphi & MS Access
Access memo field cannot be indexed, but you can certainly read and write them, filter on them etc.
RE: Delphi & MS Access
1) What is QOrg.ParamByName('test').AsString declared as?
2) Is it a ShortString or a String/ANSIString? From the little bit of Delphi that I do know, ShortStrings are limited to 255 chars - that might be where your problem is.
3) Has $LongStrings$ been turned off when building the program?
RE: Delphi & MS Access
The limit is
"65,535 when entering data through the user interface;
1 gigabyte when entering data programmatically."
But as XWB suggests I don't really think that is the problem.