|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Byte Array, DatagridHi, 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 Selva Chinnasamy wrote:
> Hi, I am reading Byte Array from MS-Access table, which I wanted to display Can you show some of your code.> in the datagrid. Right now its displayed as "Byte[] array". How can I > display the actual string. > > Any help! > > Selva > > Chris 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 Selva wrote:
Show quoteHide quote > Chris, Well I can think of a couple suggestions for you.> > 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 > 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 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 |
|||||||||||||||||||||||