Migrating Data from nVarChar to VarBinary

ScaleRichView support and discussion (TRichView add-on for WYSIWYG editing)
Post Reply
TonyBlom
Posts: 14
Joined: Sun Dec 15, 2013 12:17 pm

Migrating Data from nVarChar to VarBinary

Post by TonyBlom »

I have some old Rich View RTF data stored in nVarChar(MZX). Now I need to use VarBinary to work with SRV. I tried SQL Convert Function but it came out a mess.

Short of exporting all the data, converting then importing it, is there some way I can do the conversion ?

Thanks.
TonyBlom
Posts: 14
Joined: Sun Dec 15, 2013 12:17 pm

Additional Info

Post by TonyBlom »

I just like to add some more about the Data migration problem for me.

The old editor is just plain TRich View not SRV, and I used the DB aware version.

Thanks.
Sergey Tkachenko
Site Admin
Posts: 17559
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

I assume you added VarBinary field to the same table as contains nVarChar.

You can do the following.

Place dbsrv:TDBSRichViewEdit on the form, connect it to the source (nVarChar) field.
Let table is a data set connected to this table (and to TDBSRichViewEdit).
Let FieldName is a name of destination (VarBinary) field.

Code: Select all

var Stream: TStream; 

table.First;
while not table.EOF do begin
  table.Edit;
  Stream := table.CreateBlobStream(tbl.FieldByName(FieldName), bmWrite); 
  dbsrv.RichViewEdit.SaveRVFToStream(Stream, False); 
  Stream.Free; 
  table.Post;
  table.Next;
end;
Post Reply