Click here to Skip to main content
15,896,154 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
C#
string strProvider = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=axb.mdb";
            string strSql = "SELECT Categories , subcategories FROM Categories INNER JOIN subcategories ON Categories .Key= subcategories.Id";
            OleDbConnection con = new OleDbConnection(strProvider);
            OleDbCommand cmd = new OleDbCommand(strSql, con);
            con.Open();
            cmd.CommandType = CommandType.Text;
            OleDbDataReader dr = cmd.ExecuteReader();
 
             DataTable dtTree = new DataTable();
 
             int columnCount = dr.FieldCount;
 
             for (int i = 0; i < columnCount; i++)
             {
                 dataGridView1.Columns.Add(dr.GetName(i).ToString(), dr.GetName(i).ToString());
             }
 
 
             string[] rowData = new string[columnCount];
             while (dr.Read())
             {
                 for (int k = 0; k < columnCount; k++)
                 {
                     if (dr.GetFieldType(k).ToString() == "System.Int32")
                     {
                         rowData[k] = dr.GetInt32(k).ToString();
                     }
 
                     if (dr.GetFieldType(k).ToString() == "System.String")
                     {
                         rowData[k] = dr.GetString(k);
                     }
                 }
 
                 dataGridView1.Rows.Add(rowData);
             }

I add data to datagrid, but i can add information to treeview.
Table Categories and subcategories related to the ratio of one to many
Posted
Comments
Sergey Alexandrovich Kryukov 30-Mar-13 23:17pm    
Please stop posting non-answers as "solution". It can give you abuse reports which eventually may lead to cancellation of your CodeProject membership. And the fact you even self-accepted on formally is just outrageous, a sure way for a ban. I hope you won't do it after this warning.

Comment on any posts, reply to available comments, or use "Improve question" (above).
Also, keep in mind that members only get notifications on the post sent in reply to there posts.
—SA

1 solution

So what is the question?

See here[^]
 
Share this answer
 
Comments
[no name] 25-Dec-11 16:09pm    
it is asp.net(( i dont understand it
[no name] 26-Dec-11 7:43am    
how add data from Access DB to TreeView

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900