narasiman rao

narasiman rao

  • NA
  • 519
  • 768.5k

i tried several times but it is not working the below code

Mar 16 2013 12:23 AM
 Note it is windows application.

Run mode screen as follows;

Course Code Combo box

Datagridview as follows;

Days sess1 sess 2 sess3 sess4
1 checkbox checkbox checkbox checkbox

In Database record as follows;

courseCode Days sess1 sess2 sess3 sess4 
REO 1 checkboxchecked checkboxchecked checkboxchecked checkboxchecked 
REO 2 checkboxchecked checkboxchecked checkboxchecked checkboxchecked 

 
Then i have one button in the run mode called Search Button when click the REO Course in the combo box, in the datagridview that particular course details to be displayed in the datagridview.

 
int irows;
try
{
sql = "select [Days],[Session1],[Session2],[Session3],[Session4] from Tb_Session_Structure where Cmn_Minor_code = '" + cb_Course_Code.Text.ToString() + "' order by [Days]";
dr = GFun.ReadAcessSql1(sql);
while (dr.Read())
{
for (irows = 0; irows < DGv_Session.RowCount; irows++)
{
DGv_Session.Rows[irows].Cells[1].Value = dr[1].ToString().Trim();
DGv_Session.Rows[irows].Cells[2].Value = dr[2].ToString().Trim();
DGv_Session.Rows[irows].Cells[3].Value = dr[3].ToString().Trim();
DGv_Session.Rows[irows].Cells[4].Value = dr[4].ToString().Trim();
 
}
}
dr.Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString(), "Error");
return;
}
 
when i click the search button, the output as follows in datagridview
 
courseCode Days sess1 sess2 sess3 sess4 
REO 1 checkboxchecked checkboxchecked checkboxchecked checkboxchecked 

 
but in the database two records are there, for the REO Course in Database days 1 and 2 record is there. but when i search for the REO Course the Days 1 record only shows.
 
why what is the problem?
 
from my search code what is the mistake? i tried but it is not working.
 
Regards,

Answers (1)