Cannot Display BLOB From MS Access Database
Cannot Display BLOB From MS Access Database
Hi,
I am evaluating TRichview 1.9.24 with D7 and am connecting it to a MS Access database. All I am seeing in the edit box are a bunch of squares and letters.
How can I display the contents properly?
Thanks.
Fred
I am evaluating TRichview 1.9.24 with D7 and am connecting it to a MS Access database. All I am seeing in the edit box are a bunch of squares and letters.
How can I display the contents properly?
Thanks.
Fred
-
- Site Admin
- Posts: 17557
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
-
- Site Admin
- Posts: 17557
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
-
- Site Admin
- Posts: 17557
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
Your database has data in strange format - RTF converted to Unicode (WideString). TDBRichViewEdit does not understand it, so it reads it as a plain text, and you can see RTF codes (with space character between each RTF character).
You can use OnLoadCustomFormat event to display such fields in TDBRichView/TDBRichViewEdit:
But after editing, they will be saved back as normal RTF (if FieldFormat=RTF) (well, it's possible to save this "widestring RTF" using OnSaveCustomFormat event, but I think it makes no sense)
In addition, make the following changes:
1) Right click DBRichViewEdit1, choose "Settings" in the context menu, make sure that "Allow adding styles dynamically" is set.
2) Set DBRichViewEdit1.AutoDeleteUnusedStyles = True
You can use OnLoadCustomFormat event to display such fields in TDBRichView/TDBRichViewEdit:
Code: Select all
procedure TForm1.DBRichViewEdit1LoadCustomFormat(Sender: TCustomRichView;
Stream: TStream; var DoDefault: Boolean);
var ws: WideString;
Stream2: TStringStream;
begin
if Stream.Size mod 2 = 0 then begin
SetLength(ws, Stream.Size div 2);
Stream.ReadBuffer(Pointer(@ws[1])^, Stream.Size);
if (Length(ws)>5) and
(ws[1]='{') and (ws[2]='\') and (ws[3]='r') and (ws[4]='t') and (ws[5]='f') then begin
Stream2 := TStringStream.Create(ws);
DoDefault := not Sender.LoadRTFFromStream(Stream2);
Stream2.Free;
end;
end;
end;
In addition, make the following changes:
1) Right click DBRichViewEdit1, choose "Settings" in the context menu, make sure that "Allow adding styles dynamically" is set.
2) Set DBRichViewEdit1.AutoDeleteUnusedStyles = True
Thank you very much for your help. The database is from an application written in VB and I am converting it to be stored in DBISAM. The contents display correctly now. I will test TRichview on the entire database of 1,267 records and see if anything else crops up.
I will keep in touch on the status of my tests.
Fred
I will keep in touch on the status of my tests.
Fred
Hi,
Further to your suggestion to allow display of BLOB field from MS Access, I have converted the database contents from MS Access to DBISAM.
The following line:-
if Stream.Size mod 2 = 0 then begin // mod 1 required for DBISAM Table
cannot be used for displaying DBISAM tables because in DBISAM, the Stream.Size is not an even number. I changed the "mod 2" to "mod 1" and the display is possible. Even "mod 1" can be used for displaying MS Access tables without ill effects. Is using "mod 1" OK?
The other problem is that for one record in MS Access (or DBISAM), the program crashes with an "Index out of bounds" error when the answer field is displayed. Is it possible for you to check why this is happening? Is it a data corruption problem? If yes, can it be trapped? I have sent you the test project files.
Thanks.
Fred
Further to your suggestion to allow display of BLOB field from MS Access, I have converted the database contents from MS Access to DBISAM.
The following line:-
if Stream.Size mod 2 = 0 then begin // mod 1 required for DBISAM Table
cannot be used for displaying DBISAM tables because in DBISAM, the Stream.Size is not an even number. I changed the "mod 2" to "mod 1" and the display is possible. Even "mod 1" can be used for displaying MS Access tables without ill effects. Is using "mod 1" OK?
The other problem is that for one record in MS Access (or DBISAM), the program crashes with an "Index out of bounds" error when the answer field is displayed. Is it possible for you to check why this is happening? Is it a data corruption problem? If yes, can it be trapped? I have sent you the test project files.
Thanks.
Fred
-
- Site Admin
- Posts: 17557
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
As for the exception.
Link each DBRichViewEdit to its own TRVStyle object. The error happens because when the second editor loads from DB, it replaces collection of text, paragraph and list styles in RVStyle1, and the first editor cannot use them to display its document.
As for DBISAM.
So this conversion is not correct, it adds an extra character to data.
Ok, you can change this condition for DBISAM table, it should not do harm. But I'd recommend to convert the whole table to normal format:
After this conversion, you can remove OnLoadCustomFormat at all.
This conversion loads documents in each record in DBRichViewEdits and resaves them. Documents will be resaved in formats specified in DBRichViewEdit1.FieldFormat and DBRichViewEdit2.FieldFormat
(if they are rvdbRTF, it will be saved as RTF, if they are rvdbRVF, they will be saved in native TRichView format).
Link each DBRichViewEdit to its own TRVStyle object. The error happens because when the second editor loads from DB, it replaces collection of text, paragraph and list styles in RVStyle1, and the first editor cannot use them to display its document.
As for DBISAM.
So this conversion is not correct, it adds an extra character to data.
Ok, you can change this condition for DBISAM table, it should not do harm. But I'd recommend to convert the whole table to normal format:
Code: Select all
adoQuestion.First;
while not adoQuestion.EOF do begin
adoQuestion.Edit;
DBRichViewEdit1.Change;
DBRichViewEdit2.Change;
adoQuestion.Post;
adoQuestion.Next;
end;
This conversion loads documents in each record in DBRichViewEdits and resaves them. Documents will be resaved in formats specified in DBRichViewEdit1.FieldFormat and DBRichViewEdit2.FieldFormat
(if they are rvdbRTF, it will be saved as RTF, if they are rvdbRVF, they will be saved in native TRichView format).
Thank you for the quick answers!
I will perform the edit and save function for each record in DBISAM since this will be the final database that will be used in the new program. Also, I will create another TRvStyle and link to the second edit.
I will have the client give me all the remaining MDB databases to test and if everything turns out fine, I will purchase TRichView next week.
Thanks again.
Fred
I will perform the edit and save function for each record in DBISAM since this will be the final database that will be used in the new program. Also, I will create another TRvStyle and link to the second edit.
I will have the client give me all the remaining MDB databases to test and if everything turns out fine, I will purchase TRichView next week.
Thanks again.
Fred
Hi Sergey,
I have imported another MDB database but there is a problem with displaying pictures. Instead of a picture, I see a small icon where it should be.
I would appreciate it if you could look at the sample project files I have e-mailed to you. Look at the part just below the line that says:-
"The diagram below shows a telescope"
Another thing is the question field actually has grid lines that don't print out but are faintly visible to align the contents of the question. Can TRichview display them?
Thanks.
Fred
I have imported another MDB database but there is a problem with displaying pictures. Instead of a picture, I see a small icon where it should be.
I would appreciate it if you could look at the sample project files I have e-mailed to you. Look at the part just below the line that says:-
"The diagram below shows a telescope"
Another thing is the question field actually has grid lines that don't print out but are faintly visible to align the contents of the question. Can TRichview display them?
Thanks.
Fred
-
- Site Admin
- Posts: 17557
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
This image is in PNG format.
PNG graphic class is not included in Delphi, but you can download free thirdparty implementation from http://pngdelphi.sourceforge.net/
After that, include CRVData, PngImage in "uses", and add initialization section to your unit:
This code will allow TRichView to load and save PNG image in RTF.
PNG graphic class is not included in Delphi, but you can download free thirdparty implementation from http://pngdelphi.sourceforge.net/
After that, include CRVData, PngImage in "uses", and add initialization section to your unit:
Code: Select all
initialization
RV_RegisterPngGraphic(TPNGObject);
Thanks for the tip! The PNG image is displayed correctly when using the MDB database. However...
When I have PNGDelphi used in a unit with DBISAM 4, Delphi 7 will complain with the following error message:-
Unit Zlibcomp was compiled with a different version of zlibpas.z_errmsg
What is happening is DBISAM has a Zlibcomp.pas unit that uses its own Zlibpas.pas unit. PNGDelphi has PNGdelphi.pas using its own version of Zlibpas.pas.
How can I use both DBISAM and PNGDelphi together?
Thanks.
Fred
When I have PNGDelphi used in a unit with DBISAM 4, Delphi 7 will complain with the following error message:-
Unit Zlibcomp was compiled with a different version of zlibpas.z_errmsg
What is happening is DBISAM has a Zlibcomp.pas unit that uses its own Zlibpas.pas unit. PNGDelphi has PNGdelphi.pas using its own version of Zlibpas.pas.
How can I use both DBISAM and PNGDelphi together?
Thanks.
Fred
-
- Site Admin
- Posts: 17557
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
Hi Sergey,
I managed to get PNGDelphi to run with DBISAM by renaming the Zlibpas.pas file used by PNGDelphi and references to another name. (With help from Elevatesoft, the vendor for DBISAM)
In addition, I would like to thank you for the excellent technical support that you have provided during my evaluation process for TRichView! You can be sure that I will have more questions as I use TRichview more.
I am pleased to let you know that I am placing an order for TRichview. Also, I would like to get the discount for Addict speller. Do I get the discount from your web site or from Addictive's web site?
Thanks.
Fred
I managed to get PNGDelphi to run with DBISAM by renaming the Zlibpas.pas file used by PNGDelphi and references to another name. (With help from Elevatesoft, the vendor for DBISAM)
In addition, I would like to thank you for the excellent technical support that you have provided during my evaluation process for TRichView! You can be sure that I will have more questions as I use TRichview more.
I am pleased to let you know that I am placing an order for TRichview. Also, I would like to get the discount for Addict speller. Do I get the discount from your web site or from Addictive's web site?
Thanks.
Fred