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
Kobinath Ram
NA
130
0
how to update the qty column in datagridview in c#.
May 1 2017 9:42 AM
when i call this function only one colum has been updated couln't updated more than one colum
please help me
public void updatedb()
{
for (int row = 0; row < dataGridView1.Rows.Count - 1; row++)
{
string itmno = dataGridView1.Rows[row].Cells[1].Value.ToString();
string itmqty = dataGridView1.Rows[row].Cells[3].Value.ToString();
// string t = "select * from products where id=" + itmno + "";
// Connnew.DbSearch(t);
con.Close();
MySqlCommand scmd = new MySqlCommand();
scmd.Connection = con;
scmd.CommandText = "select * from products where id in" + itmno + "";
con.Open();
MySqlDataReader dr;
dr = scmd.ExecuteReader();
string oldqty = "", newqty = "";
while (dr.Read())
{
oldqty = dr[5].ToString();
newqty = (int.Parse(oldqty) - int.Parse(itmqty)).ToString();
}
string t2 = ("UPDATE products SET qty = '" + newqty + "' WHERE id = '" + itmno + "' ");
con.Close();
con.Open();
MySqlCommand upcmd = new MySqlCommand(t2,con);
upcmd.ExecuteNonQuery();
MessageBox.Show("Updateeeeeeeeeeeeeeeeeeeeee");
}
con.Close();
Reply
Answers (
4
)
How to use store procedure in asp classic page
validation- before and after decimal take only two digits