vb.net and sql server express binary data type

T

Ty

I have a SQL server 2000 DB that Ihave copied onto my PC and am using
SQL server express 2005 to view.

I created a project in VB.net and am reading the data out of the DB
using System.Data.SqlClient

Here is the problem. I am redaing the table fields into variables. All
are fine except one.

The table has one field that is a binary data type. This field holds
anything from a block of text to MS Word docs, Excel spread sheets,
and images.

I made the variable int a Object type "Dim vararticle As Object"

The data seems to be placed into the variable.

In this instance I know that the data is just a block of text about a
paragraphs worth. I thought I could place it into a textbox like this
TextBox1.Text = vararticle but no luck.

So the question is how do I get it out of the variable and into the
textbox?

Thanks,
Ty
 
T

Ty

Ty,

You are not ready by just setting the blob in an object.

You should have to know what kind of data it is and then stream the data
back into the proper type.

Here the code as it is an image. (Your part is method 4)

http://www.vb-tips.com/DataSetImage.aspx

Cor

"Ty" <[email protected]> schreef in bericht











- Show quoted text -

Thanks for the tip.

Once this goes into production I will not know what type of data is in
the field. The user can add just about anything.

This should get me started once I tweak it.

Thanks,
Ty
 
T

Ty

This is what I came up with that works great.

With rs.Read
Dim HoldByte() As Byte = CType(rs(0), Byte())
Dim strholder As String
For i = 0 To HoldByte.Length - 1
strholder = strholder & Chr(HoldByte(i))
Next

TextBox1.Text = strholder

End With

Thanks,
Ty
 
A

Armin Zingler

Ty said:
This is what I came up with that works great.

With rs.Read
Dim HoldByte() As Byte = CType(rs(0), Byte())
Dim strholder As String
For i = 0 To HoldByte.Length - 1
strholder = strholder & Chr(HoldByte(i))
Next

TextBox1.Text = strholder

End With

Ummm.... what do you expect to see in the Textbox? Aliens?


Armin
PS: StringBuilder class is great
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top