Hi guys,
There's a VarBinary field in the SQL Server database i need to convert to text.
The varbinary field is a document template from Microsoft word.
Is there a way to do this using VB6?
TIA
-zynder
Printable View
Hi guys,
There's a VarBinary field in the SQL Server database i need to convert to text.
The varbinary field is a document template from Microsoft word.
Is there a way to do this using VB6?
TIA
-zynder
You can try ALTER TABLEExecute using the command object like you would any other action query.Code:ALTER TABLE TableName ALTER COLUMN ColumnName NVARCHAR(20)
'of course (20) is just an example. Use how ever many characters you need
I have nothing against which to test this, but it should work.
Don't do what Hack suggested..... (Sorry Hack) it will break the field and the data stored in it. There are examples of retriving binary data from SQL Server in these forums. Varbainary will be have the same as an image (you are storing the bytes not the actual word in there). Search for saving and retirving an image to SQL Server.
Thanks for the input. I've search the VB6 section I haven't found one. Can you give me some links?
Did you even search I found this is about 30 seconds:
http://www.vbforums.com/showthread.php?t=335207
@Gary
The link is for storing. What i need is retrieving the string in varbinary data type.
Look futer there is a link in there for both storing and retrieving.
if you can't figure it out from there look here:
http://www.vbforums.com/showthread.php?t=346752
same person RB has this. It is even in his sig.
Thanks for the help. Sorry I didn't see the links on the siggy. I will let you know if it works.
I tested the code. I haven't made it to work using richtextbox as its output. The link posted is an example of extracting picture. Mine is a word document. There's probably a modification i need to make for it to work i'm still figuring it out.
I'm stumped with this. Any direct link to convert varBinary data type from SQL Server 2005 to text or put it in a richtextbox?
Read the data as shown.. Save to disk as a temp file with the extention you want (.doc,.rtf,....). open the file into your richtextbox
Ok thanks Gary I will try again.
I don't get the part with image size. I don't have a image size field on the database. How do i get around with this?
vb Code:
' Copy the data into the file. file_length = adoRST.Fields("IMAGE_SIZE") num_blocks = file_length / BLOCK_SIZE left_over = file_length Mod BLOCK_SIZE