コード例 #1
0
        static bool Do_Query(string query)
        {
            string error_msg = db.Query(query);

            if (error_msg != null)
            {
                MessageBox.Show(query + "\n\n" + error_msg, "SQL Error");
                return(false);
            }

            Console.WriteLine("\n" + query);

            if (db.HasRows)
            {
                Console.WriteLine("==========================================================");
                for (int i = 0; i < db.FieldCount; i++)
                {
                    Console.Write(db.GetName(i) + "\t");
                }
                Console.WriteLine();
                Console.WriteLine("==========================================================");

                while (db.Read())
                {
                    for (int i = 0; i < db.FieldCount; i++)
                    {
                        Console.Write(db.GetData(i) + "\t");
                    }
                    Console.WriteLine();
                }
                Console.WriteLine("==========================================================\n");
            }

            return(true);
        }
コード例 #2
0
        }//우편번호찾기()

        void 읍면동TextBox_KeyDown(object sender, KeyEventArgs args)
        {
            if (args.Key != Key.Enter) return;
            TextBox box = sender as TextBox;
            if (string.IsNullOrEmpty(box.Text)) return;

            zipDB.Open();

            string sql = string.Format("select * from ZIPTable where DONG like '{0}%' " +
                                              "order by SIDO, GUGUN, DONG, RI, BUNJI ", box.Text);

            zipDB.ExecuteReader(sql);

            //리스트박스에 있는 내용을 모두 지우고...
            우편번호폼.우편번호ListBox.Items.Clear();

            //새로 읽은 내용으로 리스트박스 채우기...
            while (zipDB.Read())
            {
                string item = "";
                item += zipDB.GetData("ZIPCODE").ToString() + " ";
                item += zipDB.GetData("SIDO").ToString() + " ";
                item += zipDB.GetData("GUGUN").ToString() + " ";
                item += zipDB.GetData("DONG").ToString() + " ";
                item += zipDB.GetData("RI").ToString() + " ";
                item += zipDB.GetData("BUNJI").ToString() + " ";

                우편번호폼.우편번호ListBox.Items.Add(item);
            }//while

            zipDB.Close();

        }