goransaler
IS-IT--Management
Hello
I'm trying to read a image from a access database
and i get a file but it's corrupt and a little bigger then the original.
I hope someone can help me.
The code i'm working on looks like this
OleDbConnection con = new OleDbConnection(@"Jet OLEDB:<<this was very long so i cut it>>";
OleDbDataAdapter oleDbDA = new OleDbDataAdapter("Select * From Artist WHERE ID=1", con);
OleDbCommandBuilder MyCB = new OleDbCommandBuilder(oleDbDataAdapter2);
DataSet ds = new DataSet("Artist");
byte[] MyData= new byte[0];
oleDbDA.Fill(ds, "Artist");
DataRow myRow;
myRow=ds.Tables["Artist"].Rows[0];
MyData = (byte[])myRow["Photo"];
int ArraySize = new int();
ArraySize = MyData.GetUpperBound(0);
FileStream fs = new FileStream(@"tmp.BMP", FileMode.OpenOrCreate, FileAccess.Write);
fs.Write(MyData, 0,ArraySize);
fs.Close();
I'm trying to read a image from a access database
and i get a file but it's corrupt and a little bigger then the original.
I hope someone can help me.
The code i'm working on looks like this
OleDbConnection con = new OleDbConnection(@"Jet OLEDB:<<this was very long so i cut it>>";
OleDbDataAdapter oleDbDA = new OleDbDataAdapter("Select * From Artist WHERE ID=1", con);
OleDbCommandBuilder MyCB = new OleDbCommandBuilder(oleDbDataAdapter2);
DataSet ds = new DataSet("Artist");
byte[] MyData= new byte[0];
oleDbDA.Fill(ds, "Artist");
DataRow myRow;
myRow=ds.Tables["Artist"].Rows[0];
MyData = (byte[])myRow["Photo"];
int ArraySize = new int();
ArraySize = MyData.GetUpperBound(0);
FileStream fs = new FileStream(@"tmp.BMP", FileMode.OpenOrCreate, FileAccess.Write);
fs.Write(MyData, 0,ArraySize);
fs.Close();