SQL Server 2008 support for filestream feature
Posted: Tue 05 May 2009 01:21
Hi,
Do you have specific support for the above?
Thanks in advance
-Mohamed
Do you have specific support for the above?
Thanks in advance
-Mohamed
Discussion forums for open issues and questions concerning database tools, data access components and developer tools from Devart
https://forums.devart.com/
Code: Select all
CREATE TABLE TESTFS(
ID INT PRIMARY KEY NOT NULL,
FS VARBINARY(MAX) FILESTREAM NULL,
GD UNIQUEIDENTIFIER UNIQUE ROWGUIDCOL NOT NULL DEFAULT NEWID()
)Code: Select all
Delphi:
MSQuery.SQL.Text := 'SELECT * FROM TESTFS';
MSQuery.Open;
MSQuery.Append;
MSQuery.FieldByName('ID').AsInteger := 1;
MSQuery.FieldByName('FS').AsString := 'TEST';
MSQuery.Post;
C++Builder:
MSQuery->SQL->Text = "SELECT * FROM TESTFS";
MSQuery->Open();
MSQuery->Append();
MSQuery->FieldByName("ID")->AsInteger = 1;
MSQuery->FieldByName("FS")->AsString = "TEST";
MSQuery->Post();Code: Select all
Delphi:
procedure TMainForm.BitBtnRunClick(Sender: TObject);
var
con: TMSConnection;
qr: TMSQuery;
fs: TMSFileStream;
ts: AnsiString;
begin
con := TMSConnection.Create(nil);
qr := TMSQuery.Create(nil);
try
con.Authentication := auWindows; // FILESTREAM requirement
con.Server := 'server';
con.Database := 'database';
qr.Connection := con;
qr.SQL.Text := 'SELECT * FROM TESTFS';
qr.Open;
//writing data
con.StartTransaction; // FILESTREAM requirement
fs := qr.GetFileStreamForField('FS', daWrite);
ts := 'TEST FILESTREAM';
fs.WriteBuffer(ts[1], Length(ts));
fs.Flush;
fs.Close; // it's necessary to call this method before the transaction commits or rolls back FILESTREAM data
con.Commit;
//reading data
con.StartTransaction; // FILESTREAM requirement
fs := qr.GetFileStreamForField('FS', daRead);
SetLength(ts, fs.Size);
fs.ReadBuffer(ts[1], fs.Size);
ShowMessage(ts);
fs.Close; // it's necessary to call this method before the transaction commits or rolls back FILESTREAM data
con.Commit;
finally
qr.Free;
con.Free;
end;
end;
C++Builder:
void __fastcall TMainForm::BitBtnRunClick(TObject *Sender)
{
TMSConnection* con = new TMSConnection(NULL);
TMSQuery* qr = new TMSQuery(NULL);
try
{
con->Authentication = auWindows; // FILESTREAM requirement
con->Server = "server";
con->Database = "database";
qr->Connection = con;
qr->SQL->Text = "SELECT * FROM TESTFS";
qr->Open();
//writing data
con->StartTransaction(); // FILESTREAM requirement
TMSFileStream* fs = qr->GetFileStreamForField("FS", daWrite);
char* ts = "TEST FILESTREAM";
fs->WriteBuffer(ts, strlen(ts));
fs->Flush();
fs->Close(); // it's necessary to call this method before the transaction commits or rolls back FILESTREAM data
con->Commit();
//reading data
con->StartTransaction(); // FILESTREAM requirement
fs = qr->GetFileStreamForField("FS", daRead);
ts = new char[fs->Size];
fs->ReadBuffer(ts, fs->Size);
ShowMessage(ts);
fs->Close(); // it's necessary to call this method before the transaction commits or rolls back FILESTREAM data
con->Commit();
}
__finally
{
qr->Free();
con->Free();
}
}