byte[] arrPicture = ((byte[]) (dsPictures.Tables[0].Rows[lstPictures.SelectedIndex]["Picture"])); MemoryStream ms = new MemoryStream(arrPicture);
PictureBox2.Image = Image.FromStream(ms);
PictureBox2.SizeMode = PictureBoxSizeMode.CenterImage;
PictureBox2.BorderStyle = BorderStyle.Fixed3D;
lblFileName.Text = dsPictures.Tables[0].Rows[lstPictures.SelectedIndex]["FileName"].ToString(); // Close the stream object to release the resource.
ms.Close();
PictureBox2.Image = Image.FromStream(ms);
PictureBox2.SizeMode = PictureBoxSizeMode.CenterImage;
PictureBox2.BorderStyle = BorderStyle.Fixed3D;
lblFileName.Text = dsPictures.Tables[0].Rows[lstPictures.SelectedIndex]["FileName"].ToString(); // Close the stream object to release the resource.
ms.Close();
根本就没用!你自己试验过吗?
再次重申!看清题目!看清题目!看清题目!看清题目!看清题目!看清题目!看清题目!看清题目!看清题目!看清题目!看清题目!看清题目!看清题目!看清题目!看清题目!看清题目!看清题目!
if(dr.Read())
{
FileInfo fi = new FileInfo("temp");
FileStream myStream=fi.Open(FileMode.Create);
byte[] mydata=((byte[])dr["imgdata"]);
//label2.Text="您现在看到的是:"+ dr["imgtitle"].ToString();
foreach(byte a in mydata)
{
myStream.WriteByte(a);
}
myStream.Close();
Image myImage=Image.FromFile("temp") ;
pic1.Image=myImage;
pic1.Refresh();
dr.Close ();
这样读呢?
BinaryWriter bw = new BinaryWriter(fs);bw.Write(MyImage);
bw.Flush();bw.Close();
fs.Close(); Image getimage=Image.FromFile("TakeOut.jpg");这个也试过了,没用,生成图片一片黑,并且报内存不足
try
{
SqlConnection northwindConnection = new SqlConnection("Server=localhost;DataBase=Northwind;Integrated Security=SSPI"); SqlCommand cmd = new SqlCommand("SELECT * " + "FROM Picture", northwindConnection);
SqlDataAdapter da; SqlCommandBuilder cbd; DataSet dsPictures; da = new SqlDataAdapter(cmd);
cbd = new SqlCommandBuilder(da);
dsPictures = new DataSet();
da.Fill(dsPictures); byte[] arrPicture = ((byte[]) (dsPictures.Tables[0].Rows[0]["Picture"])); MemoryStream ms = new MemoryStream(arrPicture);
PictureBox2.Image = Image.FromStream(ms);
PictureBox2.SizeMode = PictureBoxSizeMode.CenterImage;
PictureBox2.BorderStyle = BorderStyle.Fixed3D;