Home All Groups Group Topic Archive Search About
Author
6 Jan 2006 3:49 PM
Selva Chinnasamy
Hi, I am reading Byte Array from MS-Access table, which I wanted to display
in the datagrid. Right now its displayed as "Byte[] array". How can I
display the actual string.

Any help!

Selva

Author
6 Jan 2006 6:24 PM
Chris
Selva Chinnasamy wrote:
> Hi, I am reading Byte Array from MS-Access table, which I wanted to display
> in the datagrid. Right now its displayed as "Byte[] array". How can I
> display the actual string.
>
> Any help!
>
> Selva
>
>

Can you show some of your code.

Chris
Author
6 Jan 2006 6:46 PM
Selva
Chris,

Column Text is Binary type. Because we want to store unicode's also this was
created 7 years back where access doesnt store it as Unicode.

strSQL = "SELECT FIXEDTEXT.FixedTextRecordID, FIXEDTEXT.Text "
strSQL &= "FROM(FIXEDTEXT) "
strSQL &= "WHERE(((FIXEDTEXT.ScreenName) = '" & m_ScreenName & "')) "
strSQL &= "ORDER BY FIXEDTEXT.FixedTextRecordID"

Dim oDA As New OleDbDataAdapter(strSQL, cnLang)
Dim oDS As New DataSet

'throw a custom exception
'AddHandler oDA.FillError, AddressOf FillError

oDA.Fill(oDS, "FIXEDTEXT")

dgdFixedText.DataSource = oDS
dgdFixedText.DataMember = "FIXEDTEXT"

Looking forward your suggestions.

Selva
Author
6 Jan 2006 9:57 PM
Chris
Selva wrote:
Show quoteHide quote
> Chris,
>
> Column Text is Binary type. Because we want to store unicode's also this was
> created 7 years back where access doesnt store it as Unicode.
>
> strSQL = "SELECT FIXEDTEXT.FixedTextRecordID, FIXEDTEXT.Text "
> strSQL &= "FROM(FIXEDTEXT) "
> strSQL &= "WHERE(((FIXEDTEXT.ScreenName) = '" & m_ScreenName & "')) "
> strSQL &= "ORDER BY FIXEDTEXT.FixedTextRecordID"
>
> Dim oDA As New OleDbDataAdapter(strSQL, cnLang)
> Dim oDS As New DataSet
>
> 'throw a custom exception
> 'AddHandler oDA.FillError, AddressOf FillError
>
> oDA.Fill(oDS, "FIXEDTEXT")
>
> dgdFixedText.DataSource = oDS
> dgdFixedText.DataMember = "FIXEDTEXT"
>
> Looking forward your suggestions.
>
> Selva
>


Well I can think of a couple suggestions for you.

1. Do a one time convert of all the data in your Access table out of
binary to a nicer type.

2. After you pull the data into the datatable, loop through it and
convert it out of binary.  Look in the help file at the encoding class
to do that.

3. Make a custom DataGridTextBoxColumn that converts it for you as it
displays it.  You then will make a DataGridTableStyle and add your new
DataGridTextBoxColumn to it.  There is a lot of info around on how to
make custom columns like that.

Hope it helps
chris
Author
6 Jan 2006 10:33 PM
Cor Ligthert [MVP]
Selva,

I completely agree with Chris, for the way that you look for the way to
convert a binary array to another type, have than a look at this sample.
Yours is a little bit extraordinare therefore you will probably not find an
sample.

However you will probably need the encoding class

http://msdn2.microsoft.com/en-us/library/system.text.encoding.aspx

I hope this helps,

Cor