Hello friends! I have some database tables that store Image/Bitmap as part of each record as a Byte[]. I also have method that loads all the tables records into a DataTable and I would like some suggestions on how I can get this Byte[] column in my DataTable to be of type
System.Drawing.Image after or during the load from the DbDataReader
.
Thanks in advance!
public DataTable SelectAll(string tableName, DbConnection conn)
{
DataTable dt = new DataTable();
try
{
string query = "SELECT * FROM " + tableName;
conn.Open();
using (DbCommand cmd = GetDbCommand(query, conn))
{
using (DbDataReader dr = cmd.ExecuteReader())
{
dt.Load(dr);
}
}
}
catch (DbException ex)
{
Console.WriteLine("Exception: {0}\r\n Stack Trace: {1}", ex.Message, ex.StackTrace);
System.Diagnostics.Debugger.Break();
}
finally
{
conn.Close();
}
return dt;
}