×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Delphi & MS Access

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

RE: Delphi & MS Access

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.

RE: Delphi & MS Access

(OP)
I allready have defined field test as memo in database.
Maybe another solution?
THX
SaX

RE: Delphi & MS Access

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

RE: Delphi & MS Access

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.

RE: Delphi & MS Access

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?

RE: Delphi & MS Access

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.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members! Already a Member? Login


Resources

White Paper - Smart Manufacturing for Semiconductor
New technologies and approaches present great opportunities for semiconductor manufacturers to achieve high levels of innovation, yield and improvement. This white paper explores some of these cutting-edge technologies and how they can be applied effectively in the semiconductor industry. Read about how Smart Manufacturing is transforming the semiconductor industry. Download Now
White Paper - Analysis and Simulation in Aircraft Structure Certification
Organizations using simulation and analysis tools effectively see the benefits in their ability to achieve certification faster and with drastically less total cost than those who do not maximize these tools. Read this White Paper to learn about how digital tools such as analysis and simulation help in aircraft structure certification. Download Now

Close Box

Join Eng-Tips® Today!

Join your peers on the Internet's largest technical engineering professional community.
It's easy to join and it's free.

Here's Why Members Love Eng-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close