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
nico cedrick adriano
NA
3
942
the image doesn't update after the edit statement.
Nov 12 2014 9:24 PM
//EDIT statement
if (MessageBox.Show("Are you sure you want to Update this Existing Record??", "Update existing item", MessageBoxButtons.YesNo) == DialogResult.Yes)
{
try
{
if (textBox2.Text.Length > 0 && textBox11.Text.Length > 0)
{
string FileName = textBox11.Text;
byte[] ImageData;
fs = new FileStream(FileName, FileMode.Open, FileAccess.Read);
br = new BinaryReader(fs);
ImageData = br.ReadBytes((int)fs.Length);
//String ImageData1 = Convert.ToBase64String(ImageData);
br.Close();
fs.Close();
string CmdString = "UPDATE capilpilfile SET First = '" + textBox2.Text +
"', Middle = '" + textBox3.Text + "', Last = '" + textBox4.Text + "', Amount = '" +
textBox5.Text + "', receipt = '" + textBox6.Text + "', Address = '" + textBox7.Text +
"', TDate = '" + textBox8.Text + "', GraveID = '" + textBox9.Text + "', image = '" + ImageData +
"', handler = '" + textBox10.Text + "', imgloc = '" + textBox11.Text + "' where ID = " + id.ToString() + ";";
cmd = new MySqlCommand(CmdString, con);
cmd.Parameters.Add("@First", MySqlDbType.VarChar, 30);
cmd.Parameters.Add("@Middle", MySqlDbType.VarChar, 10);
cmd.Parameters.Add("@Last", MySqlDbType.VarChar, 30);
cmd.Parameters.Add("@Amount", MySqlDbType.VarChar, 30);
cmd.Parameters.Add("@Receipt", MySqlDbType.VarChar, 30);
cmd.Parameters.Add("@Address", MySqlDbType.VarChar, 100);
cmd.Parameters.Add("@TDate", MySqlDbType.VarChar, 30);
cmd.Parameters.Add("@GraveID", MySqlDbType.VarChar, 30);
cmd.Parameters.Add("@image", MySqlDbType.LongBlob, 50);
cmd.Parameters.Add("@handler", MySqlDbType.VarChar, 20);
cmd.Parameters.Add("@imgloc", MySqlDbType.VarChar, 200);
cmd.Parameters["@First"].Value = textBox2.Text;
cmd.Parameters["@Middle"].Value = textBox3.Text;
cmd.Parameters["@Last"].Value = textBox4.Text;
cmd.Parameters["@Amount"].Value = textBox5.Text;
cmd.Parameters["@Receipt"].Value = textBox6.Text;
cmd.Parameters["@Address"].Value = textBox7.Text;
cmd.Parameters["@TDate"].Value = textBox8.Text;
cmd.Parameters["@GraveID"].Value = textBox9.Text;
cmd.Parameters["@image"].Value = ImageData;
cmd.Parameters["@handler"].Value = textBox10.Text;
cmd.Parameters["@imgloc"].Value = textBox11.Text;
con.Open();
int RowsAffected = cmd.ExecuteNonQuery();
if (RowsAffected > 0)
{
MessageBox.Show("One record successfully UPDATED!...");
}
con.Close();
}
else
{
MessageBox.Show("Incomplete data!", "", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
finally
{
if (con.State == ConnectionState.Open)
{
con.Close();
}
}
Reply
Answers (
1
)
Relative path to a image
How Do I Convert Microsoft.Analysisservices.Adomdclient Cell