//打开数据库连接
   if( conn.State == ConnectionState.Open)
    conn.Close();   // 创建数据适配器
   string sql="SELECT * FROM IMG_TEST" ;
   SqlCommand command = new SqlCommand(sql, conn);
 
   try
   {conn.Open();}
   catch
   {
    MessageBox.Show(" 不能打开数据联接!") ;
   }
   finally
   {}
this.pic1.Image = null;
   SqlDataReader dr = command.ExecuteReader();
   if(dr.Read())
   {
    FileInfo fi = new FileInfo("temp");
if (fi.Exists == true)
    {  }
FileStream myStream=fi.Open(FileMode.Create);
    byte[] mydata=((byte[])dr["image"]);
// 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 ();

  }
  else
  { 
   MessageBox.Show("没有成功读入数据!") ;
 
  }

dr = null;  conn.Close();
上面是加载图片按钮里的代码,第一次加载总是成功的。
第二次就抱错:该进程无法访问文件“D:\Test\imgTest\WindowsApplication1\WindowsApplication1\bin\Debug\temp”,因为该文件正由另一进程使用