|
-
Mar 31st, 2011, 11:05 AM
#1
Thread Starter
Frenzied Member
Read VarBinary in SQL Server
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
-
Mar 31st, 2011, 11:42 AM
#2
Re: Read VarBinary in SQL Server
You can try ALTER TABLE
Code:
ALTER TABLE TableName ALTER COLUMN ColumnName NVARCHAR(20)
'of course (20) is just an example. Use how ever many characters you need
Execute using the command object like you would any other action query.
I have nothing against which to test this, but it should work.
-
Mar 31st, 2011, 11:52 AM
#3
Re: Read VarBinary in SQL Server
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.
Sometimes the Programmer
Sometimes the DBA
Mazz1
-
Mar 31st, 2011, 12:30 PM
#4
Thread Starter
Frenzied Member
Re: Read VarBinary in SQL Server
Thanks for the input. I've search the VB6 section I haven't found one. Can you give me some links?
-
Mar 31st, 2011, 12:46 PM
#5
Re: Read VarBinary in SQL Server
Did you even search I found this is about 30 seconds:
http://www.vbforums.com/showthread.php?t=335207
Sometimes the Programmer
Sometimes the DBA
Mazz1
-
Mar 31st, 2011, 01:08 PM
#6
Thread Starter
Frenzied Member
Re: Read VarBinary in SQL Server
@Gary
The link is for storing. What i need is retrieving the string in varbinary data type.
-
Mar 31st, 2011, 01:15 PM
#7
Re: Read VarBinary in SQL Server
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.
Sometimes the Programmer
Sometimes the DBA
Mazz1
-
Mar 31st, 2011, 01:23 PM
#8
Thread Starter
Frenzied Member
Re: Read VarBinary in SQL Server
Thanks for the help. Sorry I didn't see the links on the siggy. I will let you know if it works.
-
Mar 31st, 2011, 04:48 PM
#9
Thread Starter
Frenzied Member
Re: Read VarBinary in SQL Server
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.
-
Apr 4th, 2011, 11:07 AM
#10
Thread Starter
Frenzied Member
Re: Read VarBinary in SQL Server
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?
-
Apr 4th, 2011, 11:47 AM
#11
Re: Read VarBinary in SQL Server
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
Sometimes the Programmer
Sometimes the DBA
Mazz1
-
Apr 4th, 2011, 12:46 PM
#12
Thread Starter
Frenzied Member
Re: Read VarBinary in SQL Server
Ok thanks Gary I will try again.
-
Apr 4th, 2011, 01:50 PM
#13
Thread Starter
Frenzied Member
Re: Read VarBinary in SQL Server
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
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|