Read the image to picturebox and write it to the database.
Sqlconnection conn = new sqlconnection (@ "Data Source = chenyuming2004/vsdotnet; uid = sa; Pwd = cym; database = lhf ");
Conn. open ();
Sqlcommand cmd = new sqlcommand ("insert into Fuser values ('1a ', '1b', @ I)", Conn );
Byte [] IB = new byte [60000];
Filestream FS = new filestream (@ "D:/Windows temp/1.jpg", filemode. Open, fileaccess. Read );
FS. Read (IB, 0,60000 );
Cmd. Parameters. Add ("@ I", sqldbtype. Image, (INT) fs. Length );
Cmd. Parameters ["@ I"]. value = Ib;
Cmd. executenonquery ();
Conn. Close ();
-------------------------------------------------------
Reading images from databases to picturebox
sqlconnection conn = new sqlconnection (@ "Data Source = chenyuming2004/vsdotnet; uid = sa; Pwd = cym; database = lhf");
Conn. open ();
sqlcommand cmd = new sqlcommand ("select photo from Fuser where Password = '1b '", Conn);
sqldatareader reader = cmd. executereader ();
reader. read ();
memorystream Buf = new memorystream (byte []) Reader [0]);
image = image. fromstream (BUF, true);
picturebox1.image = image;