Sample: // Read picture into buffer byte[] bData=null; Bitmap picture; FileStream stream;// Create a new stream to load this photo into stream = new FileStream((string)dr["FullPath"], FileMode.Open, FileAccess.Read); // Create a buffer to hold the stream bytes bData = new byte[stream.Length]; // Read the bytes from this stream stream.Read(bData, 0, (int)stream.Length); picture=new Bitmap(stream); // Now we can close the stream stream.Close();//Save it into DB string strQuery="Insert into yourTable (" //Fields list +"PhotoData) "//picture data field //Fields' value +"values(" +"@PhotoData)";//Using parameter OleDbCommand oleComm=new OleDbCommand(strQuery,oleConn); oleComm.Parameters.Add("@PhotoData",PhotoData); oleComm.ExecuteNonQuery(); oleComm.Dispose();
// Read picture into buffer
byte[] bData=null;
Bitmap picture;
FileStream stream;// Create a new stream to load this photo into
stream = new FileStream((string)dr["FullPath"],
FileMode.Open,
FileAccess.Read);
// Create a buffer to hold the stream bytes
bData = new byte[stream.Length];
// Read the bytes from this stream
stream.Read(bData, 0, (int)stream.Length);
picture=new Bitmap(stream);
// Now we can close the stream
stream.Close();//Save it into DB
string strQuery="Insert into yourTable ("
//Fields list
+"PhotoData) "//picture data field
//Fields' value
+"values("
+"@PhotoData)";//Using parameter
OleDbCommand oleComm=new OleDbCommand(strQuery,oleConn);
oleComm.Parameters.Add("@PhotoData",PhotoData);
oleComm.ExecuteNonQuery();
oleComm.Dispose();