1. 将图片转为二进制存入数据库
string road = Application.StartupPath;
int index = road.LastIndexOf("bin");
string roadsub = road.Substring(0, index);
string roadNew = roadsub + "Resources\\Me.jpg";
System.IO.FileStream fs = new System.IO.FileStream(roadNew, FileMode.OpenOrCreate, FileAccess.Read);
byte[] fileByte = new byte[fs.Length];
fs.Read(fileByte, 0, (int)fs.Length);
int j = -1;
string sqlcommandText = @"insert into Picture (PContent)values(@pcontent)";
j = SqlHelper.ExecuteNonQuery(sqlcommandText, new SqlParameter("@pcontent", SqlDbType.Image) { Value = fileByte});
2.将二进制取出,转为图片显示