Ejemplo n.º 1
0
        //This ain't working yet, but i'm trying to get it to work.
        public void updatDB()
        {
            lstSubjectHeaders.Items.Clear();
            try
            {
                /*
                 * string connectionString = @"data source='messages.db'";
                 * connection = new SQLiteConnection(connectionString);
                 * connection.Open();
                 * string sqlCreateTable = "CREATE TABLE IF NOT EXISTS [messages]";
                 * sqlCreateTable += "([id] TEXT NOT NULL PRIMARY KEY,";
                 * sqlCreateTable += "[sender] TEXT NULL,[subject] TEXT NULL, [body] TEXT NULL);";
                 * SQLiteCommand cmdCreateTable = new SQLiteCommand(sqlCreateTable, connection);
                 * cmdCreateTable.ExecuteNonQuery();
                 *
                 * connection.Close();
                 */


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

                connection.Open();
                List <Msg>       dbmsg   = new List <Msg>();
                SQLiteCommand    cmdRead = new SQLiteCommand("SELECT * FROM Messages ", sqliteCon);
                SQLiteDataReader reader  = cmdRead.ExecuteReader();
                //Reading from the Database
                //
                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");
                    lstSubjectHeaders.Items.Add(data);
                    //Subjectname.Items.Add(msg.MsgSubject);

                    // sercetBox.Items.Add(msg.MsgID);
                }
                sqliteCon.Close();
            }
        }
Ejemplo n.º 2
0
        //This ain't working yet, but i'm trying to get it to work.
        public void updatDB()
        {
            lstSubjectHeaders.Items.Clear();
            try
            {

                /*
                string connectionString = @"data source='messages.db'";
                connection = new SQLiteConnection(connectionString);
                connection.Open();
                string sqlCreateTable = "CREATE TABLE IF NOT EXISTS [messages]";
                sqlCreateTable += "([id] TEXT NOT NULL PRIMARY KEY,";
                sqlCreateTable += "[sender] TEXT NULL,[subject] TEXT NULL, [body] TEXT NULL);";
                SQLiteCommand cmdCreateTable = new SQLiteCommand(sqlCreateTable, connection);
                cmdCreateTable.ExecuteNonQuery();

                connection.Close();
                */

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

                connection.Open();
                List<Msg> dbmsg = new List<Msg>();
                SQLiteCommand cmdRead = new SQLiteCommand("SELECT * FROM Messages ", sqliteCon);
                SQLiteDataReader reader = cmdRead.ExecuteReader();
                //Reading from the Database
                //
                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");
                    lstSubjectHeaders.Items.Add(data);
                    //Subjectname.Items.Add(msg.MsgSubject);

                    // sercetBox.Items.Add(msg.MsgID);
                }
                sqliteCon.Close();

            }
        }