TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Goran Bibic
482
2.9k
197.8k
Update picture c#
May 27 2018 1:00 PM
Insert picture working fine, I have problem with update...some help?
string fileName;
Upload image
private
void
buttonupload_Click(object sender, EventArgs e)
{
//Read image file
using
(OpenFileDialog ofd =
new
OpenFileDialog() { Filter =
"JPEG|*.jpg|BMP|*.bmp|PNG|*.png|All Files|*.*"
, ValidateNames =
true
, Multiselect =
false
})
{
if
(ofd.ShowDialog() == DialogResult.OK)
{
fileName = ofd.FileName;
pictureBox1.Image = System.Drawing.Image.FromFile(fileName);
}
}
}
private
void
buttonsave_Click(object sender, EventArgs e)
{
byte[] img_arr = null;
MemoryStream ms =
new
MemoryStream();
pictureBox1.Image.Save(ms, pictureBox1.Image.RawFormat);
img_arr = ms.GetBuffer();
using
(SqlConnection openCon =
new
SqlConnection(cs))
{
string saveStaff =
"INSERT INTO dbo.radnici ( data) VALUES (@data)"
;
using
(SqlCommand querySaveStaff =
new
SqlCommand(saveStaff))
{
querySaveStaff.Connection = openCon;
querySaveStaff.Parameters.AddWithValue(
"@data"
, img_arr);
openCon.Open();
querySaveStaff.ExecuteNonQuery();
openCon.Close();
}
}
else
{
using
(SqlConnection openCon =
new
SqlConnection(cs))
{
string updateStaff =
"UPDATE dbo.radnici SET data=@data WHERE id= "
+ idTextBox.Text;
using
(SqlCommand querySaveStaff =
new
SqlCommand(saveStaff))
{
queryupdateStaff.Connection = openCon;
queryupdateStaff.Parameters.AddWithValue(
"@data"
, img_arr);
openCon.Open();
queryupdateStaff.ExecuteNonQuery();
MessageBox.Show(
"UspjeĆĄno ste izmenili stavku!"
,
"Informacija"
, MessageBoxButtons.OK, MessageBoxIcon.Information);
openCon.Close();
}
}
}
Reply
Answers (
1
)
how to host web app on local IIS using public.
What is the benefits of Docker?