Beispiel #1
0
        private Collection<GraphDataSet> ExecuteReaderGDSS(string connection, string query, string column1, string column2)
        {
            DataTable dt = new DataTable();
            GraphDataSet temp;
            Collection<GraphDataSet> result = new Collection<GraphDataSet>();

            try
            {
                SQLiteConnection cnn = new SQLiteConnection(connection);
                cnn.Open();
                SQLiteCommand mycommand = new SQLiteCommand(query, cnn);
                SQLiteDataAdapter da = new SQLiteDataAdapter(mycommand);
                da.Fill(dt);
                cnn.Close();

                string lastval;
                string sno = "";
                lastval = "0";
                temp = new GraphDataSet(column1);
                if (dt.Rows.Count > 0)
                {
                    lastval = (string)dt.Rows[0][column1].ToString();
                    sno = dt.Rows[0][column2].ToString();
                    temp.Add(lastval, sno);
                    string lastserial = dt.Rows[0]["Serial"].ToString();
                    foreach (DataRow row in dt.Rows)
                    {
                        if ((row[column1] != System.DBNull.Value))
                        {
                            if (row["Serial"].ToString() == lastserial)
                            {
                                temp.Y[temp.Y.Count - 1] = double.Parse(row[column1].ToString());
                                temp.SNO[temp.Y.Count - 1] = int.Parse(dt.Rows[0][column2].ToString());
                            }
                            else
                            {
                                lastval = (string)row[column1].ToString();
                                sno = row[column2].ToString();
                                temp.Add(lastval, sno);
                            }
                        }
                        else
                        {
                            temp.Add(lastval, sno);
                        }
                        lastserial = row["Serial"].ToString();
                    }
                }
                else
                {
                    temp.Name = "empty";
                    temp.Add("0");
                    temp.Add("0");
                    temp.Add("0");
                    temp.Add("0");
                }
                result.Add(temp);
            }
            catch (SQLiteException e) { MessageBox.Show(e.Message); }
            return result;
        }
Beispiel #2
0
        //Execute Query
        private Collection<GraphDataSet> ExecuteReaderGDS(string connection, string query)
        {
            DataTable dt = new DataTable();
            GraphDataSet temp;
            Collection<GraphDataSet> result = new Collection<GraphDataSet>();

            try
            {
                SQLiteConnection cnn = new SQLiteConnection(connection);
                cnn.Open();
                SQLiteCommand mycommand = new SQLiteCommand(query, cnn);
                SQLiteDataAdapter da = new SQLiteDataAdapter(mycommand);
                da.Fill(dt);
                cnn.Close();
                string lastval;
                foreach (DataColumn x in dt.Columns)
                {
                    lastval = "0";
                    temp = new GraphDataSet(x.ColumnName);
                    foreach (DataRow row in dt.Rows)
                    {
                        if ((row[x.ColumnName] != System.DBNull.Value))
                        {
                            lastval = (string)row[x.ColumnName].ToString();
                            temp.Add(lastval);

                        }
                        else
                        {
                            temp.Add(lastval);
                        }

                    }
                    result.Add(temp);
                }
            }
            catch (SQLiteException e) { MessageBox.Show(e.Message); }
            return result;
        }