Click to See Complete Forum and Search --> : ODBC & MS Access database


sax_15
October 20th, 2005, 04:53 AM
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

exterminator
October 20th, 2005, 05:45 AM
This seems wierd because Memo can store more than 255 chars, in fact upto 65,536 characters. Is this error only coming during inserts or updates also? Make sure that you don't have this memo field in the where clause of the query. Are you using any format functions (any scalar function in general) on this memo field? An exact sample of the query that fails would help alongwith the table schema (not necessarily your original problem but something simple that would help us reproduce the bug). One last thing, did you try running the query with the memo field greater than 255 character length value directly on Access? Does it fail the same way? If not then may be this issue has something to do with the Driver. Regards.

sax_15
October 20th, 2005, 12:50 PM
The problem occurs in update and inserts statement also. I don’t use memo field in where clause (I use ID field in where clause for updates). I also don’t use any format function on memo. About trying to run query directly in Access database, everything was OK.

SQL:
UPDATE test SET test_memo="XXX......." WHERE test_id=10
INSERT INTO test (test_memo) VALUES ("XXXX....")

MS Access DB:
Table name "Test"
Fields:
test_id: Auto Number;
test_memo: Memo;