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
ullas K
NA
55
0
Updating those database records where datagridview checkbox rows is checked
Aug 14 2012 8:56 AM
I have a
datagridview
with the following columns in c#.net
1.checkboxcolumn
2.Issue Id
3.Book No
4.Book Name
5.Issue Date
6.Due Date
7.Remarks
8.Return Date
i have a
textbox
field named
Member no
i have written code in
text_leave
event to fetch issue id, book no,book name,issuedate,due date
and remarks from return table and fill the datagridview for the member no in textbox.
now what i need is to update the return table date field for rows where the checkbox field is checked.
For me only one row is updating
.what is wrong
My code is:
DateTime returndt;
int issueid;
bool chk;
for (int i = 0; i < dataGridViewEx1.Rows.Count-1; i++)
{
DataGridViewRow dr = dataGridViewEx1.Rows[i];
returndt= DateTime.Parse(dr.Cells[7].Value.ToString());
issueid=int.Parse(dr.Cells[1].Value.ToString());
chk= ((bool)dr.Cells[0].Value);
if (chk == true)
{
try
{
con = db.open();
getdata = new SqlCommand("Update bookissue_return set returned_date='" + returndt.ToString("MM/dd/yyyy") + "',return_status='R' where issue_id=" + issueid + "", con);
getdata.ExecuteNonQuery();
db.close();
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
MessageBox.Show("Records Updated Successfully", "easyLib", MessageBoxButtons.OK);
this.Dispose();
this.Close();
}
}
pls help and thanks in advance
Reply
Answers (
4
)
What's the object name of the initial form in a windows form application?
difference between typedataset and untypedataset