티스토리 뷰

카테고리 없음

sqlite treeview

뽀로로친구에디 2019. 1. 23. 11:27

 /*

        private void Treeview_Load() // 트리뷰에 들어갈 데이터베이스를 로드한다. 

        {

            treeView1.Nodes.Clear();


            SQLiteCommand cmdDataBase = new SQLiteCommand("select DISTINCT line from factory where layout_name='" + this.comboBox1.Text + "';", cn);

            cn.Open();


            SQLiteDataReader dr = cmdDataBase.ExecuteReader();


            try

            {

                while (dr.Read())

                {

                    String temp;

                    int count = 0;

                    TreeNode node = new TreeNode(dr["line"].ToString());


                    temp = dr["line"].ToString();

                    // MessageBox.Show("1");

                    SQLiteCommand cmdDataBase2 = new SQLiteCommand("select DISTINCT block from factory where layout_name='" + this.comboBox1.Text + "' and line = '" + temp + "';", cn);

                    SQLiteDataReader dr2 = cmdDataBase2.ExecuteReader();


                    while (dr2.Read())

                    {

                        String temp2;


                        temp2 = dr2["block"].ToString();

                        //MessageBox.Show("2");


                        node.Nodes.Add(temp2);

                        SQLiteCommand cmdDataBase3 = new SQLiteCommand("select DISTINCT robot from factory where layout_name='" + this.comboBox1.Text + "' and line = '" + temp + "' and block = '" + temp2 + "';", cn);

                        SQLiteDataReader dr3 = cmdDataBase3.ExecuteReader();


                        while (dr3.Read())

                        {

                            //MessageBox.Show("3");

                            node.Nodes[count].Nodes.Add(dr3["robot"].ToString());

                        }

                        count++;

                    }


                    treeView1.Nodes.Add(node);

                    treeView1.ExpandAll();

                }



            }

            catch (Exception ex)

            {

                MessageBox.Show(ex.Message);

            }


            cn.Close();


        }

        */

댓글
최근에 달린 댓글
글 보관함
«   2025/02   »
1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28
Total
Today
Yesterday
    뽀로로친구에디
    최근에 올라온 글