Esempio n. 1
0
        public void updatDB()
        {
            Subjectname.Items.Clear();
            try
            {
                SQLiteConnection sqliteCon = new SQLiteConnection(@"Data Source = messages.db;");

                sqliteCon.Open();
                List <Msg>       dbmsg   = new List <Msg>();
                SQLiteCommand    cmdRead = new SQLiteCommand("SELECT * FROM Messages ", sqliteCon);
                SQLiteDataReader reader  = cmdRead.ExecuteReader();
                //try
                //{
                while (reader.Read())
                {
                    string msgID      = reader.GetString(0);
                    string msgSender  = reader.GetString(1);
                    string msgSubject = reader.GetString(2);
                    string msgBody    = reader.GetString(3);
                    dbmsg.Add(new Msg()
                    {
                        MsgID = msgID, MsgSender = msgSender, MsgSubject = msgSubject, MsgBody = msgBody
                    });
                }



                foreach (Msg msg in dbmsg)
                {
                    ADD_NEW_DATA data = new ADD_NEW_DATA(msg.MsgSubject, msg.MsgID, "Data3");
                    Subjectname.Items.Add(data);
                    //Subjectname.Items.Add(msg.MsgSubject);

                    // sercetBox.Items.Add(msg.MsgID);
                }
                sqliteCon.Close();
            }
            catch (Exception ex)
            {
                Debug.WriteLine("Exception");
                Debug.WriteLine(ex.Message);
            }
        }
Esempio n. 2
0
        public void updatDB()
        {
            Subjectname.Items.Clear();
            try
            {

                SQLiteConnection sqliteCon = new SQLiteConnection(@"Data Source = messages.db;");

                sqliteCon.Open();
                List<Msg> dbmsg = new List<Msg>();
                SQLiteCommand cmdRead = new SQLiteCommand("SELECT * FROM Messages ", sqliteCon);
                SQLiteDataReader reader = cmdRead.ExecuteReader();
                //try
                //{
                while (reader.Read())
                {
                    string msgID = reader.GetString(0);
                    string msgSender = reader.GetString(1);
                    string msgSubject = reader.GetString(2);
                    string msgBody = reader.GetString(3);
                    dbmsg.Add(new Msg() { MsgID = msgID, MsgSender = msgSender, MsgSubject = msgSubject, MsgBody = msgBody });
                }

                foreach (Msg msg in dbmsg)
                {
                    ADD_NEW_DATA data = new ADD_NEW_DATA(msg.MsgSubject, msg.MsgID, "Data3");
                    Subjectname.Items.Add(data);
                    //Subjectname.Items.Add(msg.MsgSubject);

                    // sercetBox.Items.Add(msg.MsgID);
                }
                sqliteCon.Close();
            }
            catch (Exception ex)
            {
                Debug.WriteLine("Exception");
                Debug.WriteLine(ex.Message);
            }
        }