我想使用 DataBindign 将图片添加到数据库中,但我不知道该怎么做。这是我用来加载图像的代码:
字节[] imgData;
private void simpleButton5_Click_1(object sender, EventArgs e)
{
try
{
if (openFileDialog1.ShowDialog() == DialogResult.OK)
{
picture.ImageLocation = openFileDialog1.FileName;
imgData = File.ReadAllBytes(openFileDialog1.FileName);
}
}
catch (Exception ex)
{
// Could not load the image - probably related to Windows file system permissions.
XtraMessageBox.Show("Cannot display the image.\n You may not have permission to read the file, or " +
"it may be corrupt.\n\nReported error: " + ex.Message);
}
}