.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Forum >> Windows Application >> Post New QuestionBookmark and Share Subscribe to Forum

Updating those database records in a datagridview whose checkbox is checked

Posted By: Ullas     Posted Date: August 15, 2012    Points:5   Category :Windows Application
I have a datagridview with the following columns in c#.net windows application

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 upadating.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", "Done", MessageBoxButtons.OK);
this.Dispose();
this.Close();
}



}

pls help and thanks in advance


Responses
Author: Narayanan             
Posted Date: August 15, 2012     Points: 20   

Hi,
Please mention your error.


Regards, Lakshmi Naraayanan.S
http://dotnettechrocks.blogspot.in/


Post Reply

You must Sign In To post reply
 
 
Find more Forum Questions on C#, ASP.Net, Vb.Net, SQL Server and more Here
Quick Links For Forum Categories:
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  OOPs  SilverlightIISJQuery
JavaScript/VBScriptBiztalkWPFPatten/PracticesWCFOthers
www.DotNetSpark.comUnAnsweredAll

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend