Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations cowski on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Delphi & MS Access

Status
Not open for further replies.

sax15

Computer
Oct 20, 2005
2
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
 
Replies continue below

Recommended for you

You will need to change the data type in the Access database from 'text' to 'memo'. Access limits the size of the 'text' data type to 255 characters.
 
I allready have defined field test as memo in database.
Maybe another solution?
THX
SaX
 
This has always been a problem with MS Access as far as I know. You can store more then 255 characters into a memo field, but if you then try to handle it even in access, then you're out of luck. I know of no resolution, but I'd recommend going to one of the access newsgroups at news.microsoft.com

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
 
I dont' understand the comment "if you then try to handle it even in access, then you're out of luck"
Access memo field cannot be indexed, but you can certainly read and write them, filter on them etc.
 
The limit on memo fields in Access is 64K.

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?
 
Just a point about Access memo fields, from the help
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.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor