SQL Server Compact 4.0 and BLOBS
Posted: Sun 22 May 2011 13:03
Hi,
I'm trying to replace Access with SQL Server Compact 4 support in my application (written in Delphi 2010) and the most seems to work well.
One thing that does not seem to work properly is BLOB support.
I have tried these two versions of updating a BLOB field:
1)
(FQuery is of type TUniQuery, MS is a TMemoryStream)
with FQuery do
begin
SQL.Text := 'SELECT item_id, ItemPicture FROM tblItems WHERE item_id = 5';
Open;
try
Edit;
TBlobField(FieldByName('ItemPicture')).LoadFromStream(MS);
Post;
finally
Close;
end;
end;
The above code works well with Access, SQL Server and MySQL
2)
FQuery.Params.CreateParam(ftBlob, 'ItemPicture', ptInput);
with FQuery do
begin
SQL.Text := 'UPDATE tblItems SET ItemPicture = :ItemPicture WHERE item_id = 5';
ParamByName('ItemPicture').AsBlobRef.LoadFromStream(MS);
ExecSQL;
end;
In both cases a exception that does not help is thrown:
---------------------------
Debugger Exception Notification
---------------------------
Project Project1.exe raised exception class EOLEDBError with message 'Errors occurred. [,,,,,]'.
---------------------------
Break Continue Help
---------------------------
Anyone knows how to add BLOB support for SQL Server Compact 4 properly?
Thanks in advance.
I'm trying to replace Access with SQL Server Compact 4 support in my application (written in Delphi 2010) and the most seems to work well.
One thing that does not seem to work properly is BLOB support.
I have tried these two versions of updating a BLOB field:
1)
(FQuery is of type TUniQuery, MS is a TMemoryStream)
with FQuery do
begin
SQL.Text := 'SELECT item_id, ItemPicture FROM tblItems WHERE item_id = 5';
Open;
try
Edit;
TBlobField(FieldByName('ItemPicture')).LoadFromStream(MS);
Post;
finally
Close;
end;
end;
The above code works well with Access, SQL Server and MySQL
2)
FQuery.Params.CreateParam(ftBlob, 'ItemPicture', ptInput);
with FQuery do
begin
SQL.Text := 'UPDATE tblItems SET ItemPicture = :ItemPicture WHERE item_id = 5';
ParamByName('ItemPicture').AsBlobRef.LoadFromStream(MS);
ExecSQL;
end;
In both cases a exception that does not help is thrown:
---------------------------
Debugger Exception Notification
---------------------------
Project Project1.exe raised exception class EOLEDBError with message 'Errors occurred. [,,,,,]'.
---------------------------
Break Continue Help
---------------------------
Anyone knows how to add BLOB support for SQL Server Compact 4 properly?
Thanks in advance.