If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > Delphi, C etc > Saving a file to MS SQL Server Database (with delphi)

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 03-23-04, 06:13
mecex mecex is offline
Registered User
 
Join Date: Jan 2004
Location: Ankara Turkiye
Posts: 4
Arrow Saving a file to MS SQL Server Database (with delphi)

hi to all,

i want to save a file to a ms sql server database table
first i create a row (or column which one i dont know)
EkFile -> varbinary -> 50

then at delphi i wrote these lines

DSTemp: TAdoDataSet;
Blob: TStream;
fs: TFileStream;

if St[8] <> '' then
begin
Blob := DSTemp.CreateBlobStream(DSTemp.FieldByName('EkFile '), bmWrite);
try
Blob.Seek(0, soFromBeginning);
fs := TFileStream.Create(St[8], fmOpenRead or fmShareDenyWrite);
try
Blob.CopyFrom(fs, fs.Size);
finally
fs.Free;
end;
finally
Blob.Free;
end;
end;

it gives error "invalid typecast" at runtime
when below line executes
Blob := DSTemp.CreateBlobStream(DSTemp.FieldByName('EkFile '), bmWrite);

when i change Blob: TBlobStream
it gives error : Incompatible types TBlobStream and TStream

why ?

also
EkFile -> varbinary -> 50
what is 50 for max filesize ? 50 byte ?

thanx

MeCeX
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On