Click here to Skip to main content
15,913,773 members
Home / Discussions / C#
   

C#

 
QuestionSave Listview data to MSSQL table Pin
Tuntgerhuu23-Jan-09 19:16
Tuntgerhuu23-Jan-09 19:16 
AnswerRe: Save Listview data to MSSQL table Pin
WebMaster26-Jan-09 5:00
WebMaster26-Jan-09 5:00 
QuestionAdd Item In Combobox Pin
jigneshDPatel23-Jan-09 18:39
jigneshDPatel23-Jan-09 18:39 
AnswerRe: Add Item In Combobox Pin
Wendelius23-Jan-09 21:33
mentorWendelius23-Jan-09 21:33 
GeneralRe: Add Item In Combobox Pin
jigneshDPatel23-Jan-09 22:23
jigneshDPatel23-Jan-09 22:23 
GeneralRe: Add Item In Combobox Pin
Wendelius23-Jan-09 22:58
mentorWendelius23-Jan-09 22:58 
GeneralRe: Add Item In Combobox Pin
jigneshDPatel23-Jan-09 23:15
jigneshDPatel23-Jan-09 23:15 
GeneralRe: Add Item In Combobox Pin
Wendelius24-Jan-09 0:09
mentorWendelius24-Jan-09 0:09 
I didn't say that the problem is in the data in the database, but how you use it.

One problem is that I don't know what your method qry.FillDataSet does. Perhaps it adds rows to an existing datatable? In that case you would have too much data.

Lets make it a bit simpler (I corrected few typos I made earlier):
Data
Level_Id ParentId Level_Name
-----------------------------
2        NULL     Account
3        2        Perment
4        2        Tempray
11       NULL     Sales
12       11       tttttt
13       11       pppp
14       12       qqqqq
15       13       jjjjj
16       15       asd
17       16       sasda
20       17       fffff
23       NULL     Purchase
28       23       Pur1
30       20       qqqqqqq
31       14       aaaa
32       15       bbbbbbbb
33       32       iiiiiii
34       3        Company Employees
35       4        Contract Base Employee

public void FillCombo()
{
   DataTable dt = new DataTable();
   string sql = "select Level_Id, Level_Name from UserLevel"
              + " where Level_Name = 'Sales'";
   dt = qry.FillDataSet(sql).Tables[0];
   if (dt.Rows.Count > 1)
   {
      MessageBox.Show("Problem: More than one row");
   }
   AddChildCombo((int)dt.Rows[0]["Level_Id"], ref dt);
   this.cmbParentLevel.DataSource = dt;
   this.cmbParentLevel.DisplayMember = "Level_Name";
   this.cmbParentLevel.ValueMember = "Level_Id";
}
private void AddChildCombo(int parentLevelId,ref DataTable Table)
{
   DataTable childTable;
   string sql = "select Level_Id,Level_Name from UserLevel"
              + " where Parent_LevelId = " + parentLevelId + "";
   childTable = qry.FillDataSet(sql).Tables[0];
   <code>-- Check with debugger that rows are correctly</code>
   for ( int i = 0; i <= childTable.Rows.Count - 1; i++)
   {
      Table.ImportRow(childTable.Rows[i]);
      AddChildCombo((int)childTable.Rows[i]["Level_Id"], ref Table);
   }
}

Now use the debugger to see if row amounts and the data is correct in the FillCombo and also in the recursion.

The need to optimize rises from a bad design.My articles[^]

GeneralRe: Add Item In Combobox Pin
jigneshDPatel24-Jan-09 0:44
jigneshDPatel24-Jan-09 0:44 
GeneralRe: Add Item In Combobox Pin
Wendelius24-Jan-09 0:58
mentorWendelius24-Jan-09 0:58 
GeneralRe: Add Item In Combobox Pin
jigneshDPatel24-Jan-09 1:22
jigneshDPatel24-Jan-09 1:22 
GeneralRe: Add Item In Combobox Pin
Wendelius24-Jan-09 1:49
mentorWendelius24-Jan-09 1:49 
GeneralRe: Add Item In Combobox Pin
jigneshDPatel27-Jan-09 17:34
jigneshDPatel27-Jan-09 17:34 
GeneralRe: Add Item In Combobox Pin
Wendelius27-Jan-09 19:45
mentorWendelius27-Jan-09 19:45 
QuestionConfig Files Pin
CodingYoshi23-Jan-09 10:59
CodingYoshi23-Jan-09 10:59 
AnswerRe: Config Files Pin
Wendelius23-Jan-09 11:03
mentorWendelius23-Jan-09 11:03 
GeneralRe: Config Files Pin
CodingYoshi23-Jan-09 11:23
CodingYoshi23-Jan-09 11:23 
GeneralRe: Config Files Pin
Not Active23-Jan-09 11:29
mentorNot Active23-Jan-09 11:29 
QuestionActing on an indeterminate checkbox checkstate Pin
Lodeclaw23-Jan-09 10:34
Lodeclaw23-Jan-09 10:34 
AnswerRe: Acting on an indeterminate checkbox checkstate Pin
DaveyM6923-Jan-09 10:38
professionalDaveyM6923-Jan-09 10:38 
GeneralRe: Acting on an indeterminate checkbox checkstate Pin
Lodeclaw23-Jan-09 10:41
Lodeclaw23-Jan-09 10:41 
GeneralRe: Acting on an indeterminate checkbox checkstate Pin
DaveyM6923-Jan-09 10:57
professionalDaveyM6923-Jan-09 10:57 
GeneralRe: Acting on an indeterminate checkbox checkstate Pin
Lodeclaw23-Jan-09 11:01
Lodeclaw23-Jan-09 11:01 
GeneralRe: Acting on an indeterminate checkbox checkstate Pin
DaveyM6923-Jan-09 11:14
professionalDaveyM6923-Jan-09 11:14 
Questioncreate propertie list&lt;&gt; [modified] Pin
khaled_basher23-Jan-09 10:17
khaled_basher23-Jan-09 10:17 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.