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
Jyoti Jodha
NA
1.7k
406.9k
How to update datagridview cell value in Windows form c#
Sep 6 2017 4:50 AM
Don't show any error....
cmd =
new
SqlCommand(
"update cmpny_dtl set c_name=@c_name ,adrs=@adrs, c_phone=@c_phone, logo=@logo , state_id=@state_id where id=@id"
, con);
con.Open();
cmd.Parameters.AddWithValue(
"@id"
, id);
cmd.Parameters.AddWithValue(
"@c_name"
, CmpnyName_txt.Text);
cmd.Parameters.AddWithValue(
"@adrs"
, Adrs_txt.Text);
cmd.Parameters.AddWithValue(
"@c_phone"
, CmpnyPhone_txt.Text);
cmd.Parameters.AddWithValue(
"@state_id"
, STATE_comboBox.SelectedValue);
if
(pictureBox1.Image !=
null
)
{
MemoryStream ms =
new
MemoryStream();
pictureBox1.Image.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg);
byte
[] photo = ms.ToArray();
cmd.Parameters.AddWithValue(
"@logo"
, photo);
}
else
{
cmd.Parameters.AddWithValue(
"@logo"
, (pictureBox1.Image ==
null
) ? (
object
)DBNull.Value : pictureBox1.Image).SqlDbType = SqlDbType.Image;
}
int
k = cmd.ExecuteNonQuery();
cmd.ExecuteNonQuery();
con.Close();
if
(k > 0)
{
MessageBox.Show(k.ToString() +
"Record Inserted Successfully"
);
DisplayData();
ClearData();
}
else
{
MessageBox.Show(
"A record with a user name already exists"
, CmpnyName_txt.Text);
}
Reply
Answers (
2
)
Textbox validation for amount
System.InvalidCastException: 'Specified cast is not valid.'