Вставить картинку в datagrid?
Problem line 13 and 38..data column type is image in sql
Мне нужна классическая вставка в таблицу из picturebox
Что я уже пробовал:
String cs = "Data Source=.\\SQLEXPRESS;Initial Catalog=bss;Integrated Security=True"; if (string.IsNullOrEmpty(idTextBox.Text)) { using (SqlConnection openCon = new SqlConnection(cs)) { string saveStaff = "INSERT into dbo.poslovni_partneri (Ime, data) VALUES (@Ime,@data)"; using (SqlCommand querySaveStaff = new SqlCommand(saveStaff)) { querySaveStaff.Connection = openCon; querySaveStaff.Parameters.Add("@Ime", SqlDbType.VarChar, 255).Value = imeTextBox.Text; querySaveStaff.Parameters.Add("@data", SqlDbType.image).Value = pictureBox.Text; openCon.Open(); querySaveStaff.ExecuteNonQuery(); openCon.Close(); } } } else { using (SqlConnection openCon = new SqlConnection(cs)) { string saveStaff = "UPDATE dbo.poslovni_partneri SET Ime=@Ime, data=@data WHERE id=" + idTextBox.Text; using (SqlCommand querySaveStaff = new SqlCommand(saveStaff)) { querySaveStaff.Connection = openCon; querySaveStaff.Parameters.Add("@Ime", SqlDbType.VarChar, 255).Value = imeTextBox.Text; querySaveStaff.Parameters.Add("@data", SqlDbType.image).Value = pictureBox.Text; openCon.Open(); querySaveStaff.ExecuteNonQuery(); MessageBox.Show("Uspješno ste izmenili stavku!", "Informacija", MessageBoxButtons.OK, MessageBoxIcon.Information); openCon.Close(); } } } /////////For upload picture in picture box use this code and it work... private void button4_Click(object sender, EventArgs e) { //Read image file using (OpenFileDialog ofd = new OpenFileDialog() { Filter = "JPEG|*.jpg", ValidateNames = true, Multiselect = false }) { if (ofd.ShowDialog() == DialogResult.OK) { fileName = ofd.FileName; lblFilename.Text = fileName; dataPictureBox1.Image = System.Drawing.Image.FromFile(fileName); } } }