数据库Image里有张ImageStore表,表中有一个字段ImagePro (数据类型是Image),我在前台想通过移动记录来浏览数据库里面的图片,在Form_Load里面的代码如下:
try
{
string MySQL = "Select * From ImageStore ";
SqlConnection MyConnection = new SqlConnection("Data Source=.;Initial Catalog=Image;Integrated Security=True");
MyConnection.Open();
SqlDataAdapter MyAdapter = new SqlDataAdapter(MySQL, MyConnection);
MyAdapter.Fill(this.dataSet1, "ImageStore");
this.pictureBox1.DataBindings.Add(new Binding("Image", this.dataSet1, "ImageStore.ImagePro"));
//MyBind = this.BindingContext[this.dataSet1, "ImageStore"];
MyBind=this.pictureBox1.BindingContext[this.dataSet1,"ImageStore"];
MyConnection.Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
但是运行 提示:无法将直格式化为所需类型,请问该怎么解决呢?