Click here to Skip to main content
14,743,331 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I use WindowsForm with C# and Visual Studio 16.8.1

Can you read a Blob field (MySql db) via Binding ?

I find it possible to do so with Binary (BLOB) fields containing Images, via "Image" and Varchar with "Text", but with Bynary (BLOB) containing text ?


What I have tried:

suppose the Blob contains the text
test text on blob field


//read Blob field from a DataTable with DataRow
NoteF = (byte[])(row["tag"]);   

//read Byte 
NoteImgPrec += Encoding.UTF8.GetString(NoteF).Trim();


//with DataSet and Binding source
//ImageDataSet is a PictureBox
//tbFile is a TextBox

//PictureBox from Blob field - image is visible
ImageDataSet.DataBindings.Add(new Binding("Image", bs, "immagine", true));

//Textbox from Text field - text is visible
tbFile.DataBindings.Add(new Binding("Text", bs, "namefile", true));

//Blob field from Blob field
//is possible to assign 
//with Binding type for ????

tbNote.DataBindings.Add(new Binding("????" , bs, "tag", false)); 


//if I use
tbNote.DataBindings.Add(new Binding("Text" , bs, "tag", false)); 

//the result is Byte[] Array
Posted
Updated 17-Nov-20 13:27pm

1 solution

Just convert the byte array to a string and assign it to the .Text property. Or convert, then assign it to some other bind-able property.

https://codingexplained.com/coding/csharp/convert-byte-array-to-string-in-c-sharp[^]
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900