Has anyone had any success writing a a zip file into a varbinary data type in SQL Server?
Here is a snipped of my code:
//----------------------- Write record to database -----------------------------//
ll_fileln = FileLength(ls_zipfile)
li_fnum = FileOpen(ls_zipfile, StreamMode!, Read!)
If li_fnum < 0 Then Return -1
// Determine the number of reads required to read the entire file
If ll_fileln > 32765 Then
If Mod(ll_fileln, 32765) = 0 Then
li_reads = ll_fileln / 32765
Else
li_reads = (ll_fileln / 32765) + 1
End if
Else
li_reads = 1
End if
// Read the file and build the blob with data from the file
For li_cnt = 1 to li_reads
If FileRead(li_fnum, lbl_string) = -1 Then
Return -1
Else
lbl_string2 = lbl_string2 + lbl_string
End if
Next
lbl_string2 = blob(string(lbl_string2), EncodingUTF16LE!)
FileClose(li_fnum)
insert into aus_bpc.dbo.mps_data (mps_id, mps_session_id, mps_request, mps_request_date, lst_upd_user_id, lst_up_dtm ) values ( :ll_mps_id, :ls_session, CONVERT(varbinary(max), :lbl_string2), getdate(), :gsUserID, getdate());
problem here is what gets written is not usable. Any help would be greatly appreciated.