Tanx for replay
its work and I use TVirtualtable in my programs very good and useful
I leave my experience for other users
Search found 5 matches
- Thu 26 Aug 2021 12:58
- Forum: VirtualDAC
- Topic: Save And Load VarChar(Max) As Blob or string From Virtualtable
- Replies: 5
- Views: 22312
- Fri 13 Aug 2021 07:17
- Forum: VirtualDAC
- Topic: how to assign ftStream
- Replies: 1
- Views: 19359
how to assign ftStream
I Have a virtual table with ftStream field
how I can assign a value to this field?
how I can assign a value to this field?
- Wed 30 Jun 2021 11:42
- Forum: VirtualDAC
- Topic: Save And Load VarChar(Max) As Blob or string From Virtualtable
- Replies: 5
- Views: 22312
Re: Save And Load VarChar(Max) As Blob or string From Virtualtable
To save and load like a NvarChar(Max)
1- Function that convert TMemoryStream to widestring
2- procedure that let you to load a Memorystream into a widestring
3- now save a virtualtable(TVar) into a sqlserver and load it again into another one
(some variables can remove)
1- Function that convert TMemoryStream to widestring
Code: Select all
function Mem2WS(MemoryStream : TMemoryStream): string;
var
StringStream: TStringStream;
begin
Result:='';
StringStream:= TStringStream.Create('');
try
MemoryStream.Position := 0;
StringStream.CopyFrom(MemoryStream, MemoryStream.Size);
Result:= StringStream.DataString;
Result := Result;
finally
FreeAndNil(StringStream);
end;
end;
Code: Select all
procedure WS2Mem(S: string; Var K : TMemoryStream);
var
StringStream: TStringStream;
begin
StringStream:=TStringStream.Create(S);
K:=TMemoryStream.Create;
K.Position := 0;
K.CopyFrom(StringStream,StringStream.Size);
end;
(some variables can remove)
Code: Select all
procedure TForm1.Button1Click(Sender: TObject);
var
A, K: TMemoryStream;
begin
// save sample table
A := TMemoryStream.Create;
TVars.SaveToStream(A);
MSTable1.Insert;
MSTable1.FieldByName('aa').AsString := Mem2WS(A);
MSTable1.Post;
A.Free;
// load from SQLServer
A := TMemoryStream.Create;
WS2Mem(MSTable1.FieldByName('aa').AsString,K) ;
VirtualTable1.LoadFromStream(K, True, False);
VirtualTable1.Active := True;
A.Free;
end;
- Tue 29 Jun 2021 17:31
- Forum: VirtualDAC
- Topic: Save And Load VarChar(Max) As Blob or string From Virtualtable
- Replies: 5
- Views: 22312
Re: Save And Load VarChar(Max) As Blob or string From Virtualtable
Oh I forget
Dont use Ftstring
Just use FtWideString
with use string may you have this message
Dont use Ftstring
Just use FtWideString
with use string may you have this message
Code: Select all
"raised exception class EReadError with message 'Stream read error'."
- Fri 25 Jun 2021 11:18
- Forum: VirtualDAC
- Topic: Save And Load VarChar(Max) As Blob or string From Virtualtable
- Replies: 5
- Views: 22312
Save And Load VarChar(Max) As Blob or string From Virtualtable
Hi every body
I looking for this topic about 3 hour , and I collect what I found for next refer and share it with you
I hope you like it
1- we have a virtual table on screen and fill it
2- to save in a stream we can use
3- we like to save it to MsSql database
4- We like to save it as a string
5- get data from table and post load into another virtual table
I looking for this topic about 3 hour , and I collect what I found for next refer and share it with you
I hope you like it
1- we have a virtual table on screen and fill it
2- to save in a stream we can use
Code: Select all
Var
NN,K :TMemoryStream;
procedure TForm1.Button1Click(Sender: TObject);
begin
NN:=TMemoryStream.Create;
VirtualTable1.SaveToStream(NN,True,True);
Code: Select all
begin
MSTable1.Insert;
TBlobField(MSTable1.FieldByName('a')).LoadFromStream(NN);
MSTable1.Post;
Code: Select all
function MemoryStreamToString(M: TMemoryStream): string;
begin
SetString(Result, PChar(M.Memory), M.Size div SizeOf(Char));
end;
var
S : TStringList;
begin
S:=TStringList.Create;
S.Add('');
S[0]:=MemoryStreamToString(NN);
MSTable1.Insert;
MSTable1.FieldByName('a').AsString:=S[0];
MSTable1.Post;
Code: Select all
K:=TMemoryStream.Create;
TBlobField(MSTable1.FieldByName('a')).SaveToStream(K);
VirtualTable2.LoadFromStream(K,True,False);
VirtualTable2.Active:=True;