Hi!
I wrote this codes to download my pictures. Its works well. Then each time I want I would like to save pictures in my database.
But sound that my saving's codes are wrong and there is a red line on this line:
I have this message: "Cannot implicitly convert type 'System.Drawing.Image'". An explicit
conversion exists (are you missing a cast?)
Can I have some help...
I wrote this codes to download my pictures. Its works well. Then each time I want I would like to save pictures in my database.
But sound that my saving's codes are wrong and there is a red line on this line:
pictureBox1.Image = dRow.ItemArray.GetValue(3);
I have this message: "Cannot implicitly convert type 'System.Drawing.Image'". An explicit
conversion exists (are you missing a cast?)
Can I have some help...
private void NavigateRecords()
{
DataRow dRow = ds1.Tables["Avi"].Rows[inc];
txtBx_Name.Text = dRow.ItemArray.GetValue(1).ToString();
txtBx_Birthday.Text = dRow.ItemArray.GetValue(2).ToString();
pictureBox1.Image = dRow.ItemArray.GetValue(3);
}
private void btnSave_Click(object sender, EventArgs e)
{
DataRow dRow = ds1.Tables["Avi"].NewRow();
dRow[1] = txtBx_Name.Text;
dRow[2] = txtBx_Birthday.Text;
dRow[3] = pictureBox1.Image;
ds1.Tables["Avi"].Rows.Add(dRow);
UpdateDB();
MaxRows = MaxRows + 1;
inc = MaxRows - 1;
btnAdd.Enabled = true;
btnSave.Enabled = false;
}
private void btnDownload_Click(object sender, EventArgs e)
{
string Chosen_File = "";
openFileDialog1.InitialDirectory = "C:";
openFileDialog1.Title = "Insert an Image";
openFileDialog1.FileName = "";
openFileDialog1.Filter = "JPEG Images|*.jpg|GIF Images|*.gif";
if (openFileDialog1.ShowDialog() == DialogResult.Cancel)
{
MessageBox.Show("Operation Cancelled");
}
else
{
Chosen_File = openFileDialog1.FileName;
pictureBox1.Image = Image.FromFile(Chosen_File);
}