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

Re: vb.net and sql server express binary data type by Cor

Cor
Sun May 11 09:28:21 CDT 2008

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" <tbarton@lewistownhospital.org> schreef in bericht
news:9e4b282b-f386-4e51-99d1-2bd8db508f33@f63g2000hsf.googlegroups.com...
>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


Re: vb.net and sql server express binary data type by Ty

Ty
Sun May 11 09:56:15 CDT 2008

On May 11, 10:28=A0am, "Cor Ligthert[MVP]" <notmyfirstn...@planet.nl>
wrote:
> 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" <tbar...@lewistownhospital.org> schreef in berichtnews:9e4b282b-f386-=
4e51-99d1-2bd8db508f33@f63g2000hsf.googlegroups.com...
>
>
>
> >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 =3D vararticle but no luck.
>
> > So the question is how do I get it out of the variable and into the
> > textbox?
>
> > Thanks,
> > Ty- Hide quoted text -
>
> - 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

Re: vb.net and sql server express binary data type by Ty

Ty
Mon May 12 05:25:23 CDT 2008

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


Re: vb.net and sql server express binary data type by Armin

Armin
Mon May 12 07:06:17 CDT 2008

"Ty" <tbarton@lewistownhospital.org> schrieb
> 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