Problem line 13 and 38..data column type is image in sql
Or some recomandition to insert into and update pciture from picture box
- 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();
- }
- }
- }
- 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);
- }
- }
- }
Rafnas T PPosted Apr 6, 2018, 1:50 AM
Goran BibicPosted Apr 6, 2018, 1:49 AM
Goran BibicPosted Apr 6, 2018, 1:46 AM
Rafnas T PPosted Apr 6, 2018, 1:44 AM
Amit GuptaPosted Apr 5, 2018, 4:32 PM