I'm sorry to post a seemingly topic-irrelated problem. In my servlet, I want to store a
text file(such as .doc) and a image file(such as .jpg) to the fields 'text' or 'image' of
MS SQL Server 6.5. But I don't know how to store and how to retrieve them.
I've searched archives with no luck.
 
Some codes are
 
      RandomAccessFile f = new RandomAccessFile(
         "servlets\\MediaFiles\\"+fileName[0], "r");
      int size = (int)f.length();
      byte[] buff = new byte[size];
      f.readFully(buff, 0, size);
 
I use "declare @imgpageptr varbinary(16)
select @pageptr=textptr(ImgCol) from sqltbl where Rowid = 1
write sqltbl.imgCol @pageptr with log" + buff
(or readtext sqltbl.imgCol @pageptr 0  0)
 
Am I making an obvious mistake.
 
Could someone here help me out please.
 
thanks,
 
Kehao
 
 

Reply via email to