Server
Read the picture to PictureBox, then write 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\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 ();
-------------------------------------------------------
Read pictures from database to PictureBox
SqlConnection conn=new SqlConnection (@ "Data source=chenyuming2004\vsdotnet;uid=sa;pwd=cym;database=lhf");
Conn. Open ();
SqlCommand cmd=new SqlCommand ("Select photos from fuser where password= ' 1b '", conn);
SqlDataReader Reader=cmd. ExecuteReader ();
Reader. Read ();
MemoryStream buf=new MemoryStream ((byte[)) reader[0]);
Image Image=image.fromstream (buf,true);
Picturebox1.image=image;