搞了N久还没解决,新手就这么难做?
请问如何将PictureBox控件显示的图片保存到数据库Image类型的字段中?请高手帮忙解决,最好能给个代码示例.谢谢……
------解决方案--------------------www.cnblogs.com/kwklover
------解决方案--------------------两个网址拼起来,后面那个全角改半角 
 靠 
 CSDN在搞什么啊? 
 这么简单的地址不让我发
------解决方案--------------------给你指一条学习C#最快的方法,使用《程序员秘书》,有了它你不用这样辛苦的求人了。 
 详见:http://www.psec.net.cn   
 摘录:《程序员秘书》--源代码--数据库--图片文件写入数据库并读出 
 9、在Form1.cs的视图设计器中,选中button2,在属性框中选中事件,双击Click,在Form1.cs的代码设计器中,添加修改如下代码 
 private void button2_Click(object sender, EventArgs e) 
 { 
     try 
     { 
         OpenFileDialog openFileDialog1 = new OpenFileDialog(); 
         if (openFileDialog1.ShowDialog() == DialogResult.OK) 
         { 
             string FileName = Path.GetFileName(openFileDialog1.FileName); 
             if (listBox1.Items.IndexOf(FileName) == -1) 
             { 
                 Stream myStream = openFileDialog1.OpenFile(); 
                 int length = (int)myStream.Length; 
                 byte[] bytes = new byte[length]; 
                 myStream.Read(bytes, 0, length); 
                 myStream.Close(); 
                 dataset.Tables[0].Rows.Add(new object[] { FileName, bytes }); 
                 adapter.Update(dataset,  "Pic_Table ");//保存到数据库 
                 listBox1.Items.Add(dataset.Tables[0].Rows[dataset.Tables[0].Rows.Count - 1][0].ToString()); 
                 listBox1.SelectedIndex = listBox1.Items.Count-1; 
                 MessageBox.Show(this,  "已经添加了一个图片。 ",  "信息提示 ", MessageBoxButtons.OK, MessageBoxIcon.Information); 
             } 
             else 
                 MessageBox.Show(this,  "添加的图片名称已经存在。 ",  "信息提示 ", MessageBoxButtons.OK, MessageBoxIcon.Information); 
         } 
     } 
     catch (Exception Mye) 
     { 
         MessageBox.Show(this, Mye.Message,  "信息提示 ", MessageBoxButtons.OK, MessageBoxIcon.Error); 
     } 
 }   
 你可以先将PictureBox的图片保存为一个临时文件,再用上面的方法处理就OK了。
------解决方案--------------------byte[] bytes; 
 IO.MemeryStream ms= new IO.MemeryStream(); 
 PictureBox1.Image.Save(ms, Imaging.ImageFormat.Jpeg); 
 bytes=ms.ToArray(); 
 string sql= "insert table (img) values (@img) "; 
 SqlCommand cmd = new SqlCommand(sql,MyCon); 
 SqlParameter param = new SqlParameter( "@img ",SqlDbType.Image); 
 param.Value=bytes; 
 cmd.Parameters.Add(param);