Example #1
0
        public static DBWatchers GetData(string number)
        {
            DBWatchers data = null;

            SQLiteConnection con = DBConnection.ConnectDatabase();

            try
            {
                SQLiteCommand    cmd    = new SQLiteCommand("SELECT * FROM " + tablename + " WHERE number='" + number + "'", con);
                SQLiteDataReader reader = cmd.ExecuteReader();

                if (reader.HasRows)
                {
                    reader.Read();
                    data = new DBWatchers();

                    data.Number       = reader.GetString(0);
                    data.Municipality = reader.GetString(1);
                    data.Precinct_no  = reader.GetString(2);
                }

                reader.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                con.Close();
            }

            return(data);
        }
Example #2
0
        public static List <DBWatchers> GetDataList()
        {
            List <DBWatchers> data = new List <DBWatchers>();

            SQLiteConnection con = DBConnection.ConnectDatabase();

            try
            {
                SQLiteCommand    cmd    = new SQLiteCommand("SELECT * FROM " + tablename, con);
                SQLiteDataReader reader = cmd.ExecuteReader();

                if (reader.HasRows)
                {
                    while (reader.Read())
                    {
                        DBWatchers rawData = new DBWatchers();
                        rawData.Number       = reader.GetString(0);
                        rawData.Municipality = reader.GetString(1);
                        rawData.Precinct_no  = reader.GetString(2);

                        data.Add(rawData);
                    }
                }

                reader.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                con.Close();
            }

            return(data);
        }