ExecuteReader() public method

public ExecuteReader ( ) : SQLiteDataReader
return SQLiteDataReader
Example #1
0
        public bool FindIDByName(string FirstNameToFind, string LastNameToFind)
        {
            SQLiteConnection m_dbConnection = new SQLiteConnection("Data Source=C:\\IDDBShared\\IDDatabase.sqlite;Version=3;");
            m_dbConnection.Open();
            string sql = "select * from Users";
            SQLiteCommand command = new SQLiteCommand(sql, m_dbConnection);
            SQLiteDataReader reader = command.ExecuteReader();

            bool userDNE = true;
            while (reader.Read())
            {
                string currentFirstName = Convert.ToString(reader["firstName"]);
                string currentLastName = Convert.ToString(reader["lastName"]);
                if (currentFirstName == FirstNameToFind && currentLastName == LastNameToFind)
                {
                    UserName.Content = reader["firstName"] + " " + reader["lastName"];
                    IDNumber.Content = Convert.ToString(reader["IDNumber"]);
                    StartingBalance.Content = "$" + Convert.ToString(reader["beginningBalance"]);
                    Current_Balance.Content = "$" + Convert.ToString(reader["currentBalance"]);
                    string photoLocation = Convert.ToString(reader["photo"]);
                    IMGUserPhoto.Source = new BitmapImage(new Uri(photoLocation));
                    userDNE = false;
                }
            }

            return userDNE;
        }
        public static AttendanceReport[] GetAttendaceSummaryReports(string data_path)
        {
            SQLiteConnection conn = new SQLiteConnection(@"Data Source=" + data_path);
            conn.Open();

            SQLiteCommand cmd = new SQLiteCommand(conn);
            cmd.CommandText = "select * from AttendanceSummary";

            SQLiteDataReader reader = cmd.ExecuteReader();

            List<AttendanceReport> attendanceReports = new List<AttendanceReport>();
            while (reader.Read())
            {
                int ID = reader.GetInt32(0);
                string timeIN = reader.GetString(1);
                string timeOUT = reader.GetString(2);
                string deltaTime = reader.GetString(3);
                string activity = reader.GetString(4);
                string mentor = reader.GetString(5);
                int index = reader.GetInt32(6);

                attendanceReports.Add(new AttendanceReport(ID, timeIN, timeOUT, deltaTime, activity, mentor, index));
            }
            reader.Close();
            conn.Close();
            return attendanceReports.ToArray();
        }
Example #3
0
        protected internal static Bitmap RetrieveImage(int imgid)
        {
            using (SQLiteCommand command = new SQLiteCommand("select image from images where [email protected]", FetchDbConn()))
            {
                command.Parameters.Add(new SQLiteParameter("@imgid", imgid));

                using (SQLiteMonDataReader reader = new SQLiteMonDataReader(command.ExecuteReader()))
                {
                    if (!reader.Read())
                    {
                        return null;
                    }

                    // Get the size of the image data by passing nothing to getbytes
                    int dataLength = (int)reader.GetBytes(reader.GetOrdinal("image"), 0, null, 0, 0);
                    byte[] content = new byte[dataLength];

                    reader.GetBytes(reader.GetOrdinal("image"), 0, content, 0, dataLength);

                    using (MemoryStream contentStream = new MemoryStream(content))
                    {
                        using (Bitmap streamBitmap = new Bitmap(contentStream))
                        {
                            return new Bitmap(streamBitmap);
                        }
                    }
                }
            }
        }
Example #4
0
        public static DataTable GetDataTable(string sql)
        {
            DataTable dt = new DataTable();

            try

            {

                SQLiteConnection cnn = new SQLiteConnection(@"Data Source=C:\Projects\showdownsharp\db\showdown.db");

                cnn.Open();

                SQLiteCommand mycommand = new SQLiteCommand(cnn);

                mycommand.CommandText = sql;

                SQLiteDataReader reader = mycommand.ExecuteReader();

                dt.Load(reader);

                reader.Close();

                cnn.Close();

            } catch {

            // Catching exceptions is for communists

            }

            return dt;
        }
Example #5
0
        private List<Result> QuerySqllite(Doc doc, string key)
        {
            string dbPath = "Data Source =" + doc.DBPath;
            SQLiteConnection conn = new SQLiteConnection(dbPath);
            conn.Open();
            string sql = GetQuerySqlByDocType(doc.DBType).Replace("{0}", key);
            SQLiteCommand cmdQ = new SQLiteCommand(sql, conn);
            SQLiteDataReader reader = cmdQ.ExecuteReader();

            List<Result> results = new List<Result>();
            while (reader.Read())
            {
                string name = reader.GetString(reader.GetOrdinal("name"));
                string docPath = reader.GetString(reader.GetOrdinal("path"));

                results.Add(new Result
                    {
                        Title = name,
                        SubTitle = doc.Name.Replace(".docset", ""),
                        IcoPath = doc.IconPath,
                        Action = (c) =>
                            {
                                string url = string.Format(@"{0}\{1}\Contents\Resources\Documents\{2}#{3}", docsetPath,
                                                           doc.Name+".docset", docPath, name);
                                string browser = GetDefaultBrowserPath();
                                Process.Start(browser, String.Format("\"file:///{0}\"", url));
                                return true;
                            }
                    });
            }

            conn.Close();

            return results;
        }
Example #6
0
        public SkillSet(ToonClass @class, Toon toon)
        {
            [email protected] = @class;

            var query = string.Format("SELECT * FROM active_skills WHERE id_toon={0}", toon.PersistentID);
            var cmd = new SQLiteCommand(query, DBManager.Connection);
            var reader = cmd.ExecuteReader();
            if (!reader.HasRows)
            {
                int[] ActiveSkillsList = Skills.GetAllActiveSkillsByClass([email protected]).Take(1).ToArray();

                this.ActiveSkills = new ActiveSkillSavedData[6] {
                    new ActiveSkillSavedData { snoSkill = ActiveSkillsList[0], snoRune = -1 },
                    new ActiveSkillSavedData { snoSkill = Skills.None, snoRune = -1 },
                    new ActiveSkillSavedData { snoSkill = Skills.None, snoRune = -1 },
                    new ActiveSkillSavedData { snoSkill = Skills.None, snoRune = -1 },
                    new ActiveSkillSavedData { snoSkill = Skills.None, snoRune = -1 },
                    new ActiveSkillSavedData { snoSkill = Skills.None, snoRune = -1 }
                };
                this.PassiveSkills = new int[3] { -1, -1, -1 };

                var insQuery = string.Format("INSERT INTO active_skills (id_toon,"+
                    "skill_0,skill_1,skill_2,skill_3,skill_4,skill_5,"+
                    "rune_0,rune_1,rune_2,rune_3,rune_4,rune_5,"+
                    "passive_0,passive_1,passive_2) VALUES ({0},{1},-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1 )",
                                 toon.PersistentID, ActiveSkillsList[0]);
                var insCmd = new SQLiteCommand(insQuery, DBManager.Connection);
                insCmd.ExecuteNonQuery();
            }
            else
            {
                this.ActiveSkills = new ActiveSkillSavedData[6] {
                    new ActiveSkillSavedData {  snoSkill = Convert.ToInt32(reader["skill_0"]), 
                                                snoRune  = Convert.ToInt32(reader["rune_0"]) },
                    new ActiveSkillSavedData {  snoSkill = Convert.ToInt32(reader["skill_1"]), 
                                                snoRune  = Convert.ToInt32(reader["rune_1"]) },
                    new ActiveSkillSavedData {  snoSkill = Convert.ToInt32(reader["skill_2"]), 
                                                snoRune  = Convert.ToInt32(reader["rune_2"]) },
                    new ActiveSkillSavedData {  snoSkill = Convert.ToInt32(reader["skill_3"]), 
                                                snoRune  = Convert.ToInt32(reader["rune_3"]) },
                    new ActiveSkillSavedData {  snoSkill = Convert.ToInt32(reader["skill_4"]), 
                                                snoRune  = Convert.ToInt32(reader["rune_4"]) },
                    new ActiveSkillSavedData {  snoSkill = Convert.ToInt32(reader["skill_5"]), 
                                                snoRune  = Convert.ToInt32(reader["rune_5"]) }
                };
                this.PassiveSkills = new int[3] {
                    Convert.ToInt32(reader["passive_0"]),
                    Convert.ToInt32(reader["passive_1"]),
                    Convert.ToInt32(reader["passive_2"])
                };
            }
            this.HotBarSkills = new HotbarButtonData[6] {
                new HotbarButtonData { SNOSkill = ActiveSkills[0].snoSkill, Field1 = -1, ItemGBId = -1 }, // left-click
                new HotbarButtonData { SNOSkill = ActiveSkills[1].snoSkill, Field1 = -1, ItemGBId = -1 }, // right-click
                new HotbarButtonData { SNOSkill = ActiveSkills[2].snoSkill, Field1 = -1, ItemGBId = -1 }, // bar-1
                new HotbarButtonData { SNOSkill = ActiveSkills[3].snoSkill, Field1 = -1, ItemGBId = -1 }, // bar-2
                new HotbarButtonData { SNOSkill = ActiveSkills[4].snoSkill, Field1 = -1, ItemGBId = -1 }, // bar-3
                new HotbarButtonData { SNOSkill = ActiveSkills[5].snoSkill, Field1 = -1, ItemGBId = -1 }, // bar-4
            };
        }
 public static DataTable buscaSing4()
 {
     DataTable tabla = new dataCredito.sing4DataTable();
     using (SQLiteConnection con = new SQLiteConnection(Datos.conexion))
     {
         using (SQLiteCommand comando = new SQLiteCommand())
         {
             comando.CommandText = "select * from sing4";
             comando.Connection = con;
             con.Open();
             SQLiteDataReader lector = comando.ExecuteReader();
             while (lector.Read())
             {
                 DataRow fila = tabla.NewRow();
                 fila["encabezado"] = lector.GetString(0);
                 fila["saludo"] = lector.GetString(1);
                 fila["pie"] = lector.GetString(2);
                 fila["asesor"] = lector.GetString(3);
                 fila["fecha"] = lector.GetDateTime(4);
                 fila["id"] = lector.GetString(5);
                 fila["idCliente"] = lector.GetInt32(6);
                 tabla.Rows.Add(fila);
             }
         }
         con.Close();
     }
     return (tabla);
 }
Example #8
0
        public static void Test( )
        {
            using( var connection = new SQLiteConnection( ConnectionString ) )
            {
                connection.Open( );

                var command = new SQLiteCommand( "CREATE TABLE IF NOT EXISTS Blaat( Id INTEGER PRIMARY KEY NOT NULL, A, B )", connection );
                command.ExecuteNonQuery( );

                command = new SQLiteCommand( "INSERT INTO Blaat (A,B) VALUES( 1,2 )", connection );
                command.ExecuteNonQuery( );

                command = new SQLiteCommand( "INSERT INTO Blaat (A,B) VALUES( 3,4 )", connection );
                command.ExecuteNonQuery( );

                command = new SQLiteCommand( "SELECT * FROM BLAAT", connection );
                using( var reader = command.ExecuteReader( ) )
                {
                    while( reader.Read( ) )
                    {
                        Debug.WriteLine( string.Format( "(DIRECT)VALUES --> {0}:{1},{2}", reader.GetValue( 0 ), reader.GetValue( 1 ), reader.GetValue( 2 ) ) );
                    }

                    reader.Close( );
                }

                //command = new SQLiteCommand( "DROP TABLE BLAAT", connection );
                //command.ExecuteNonQuery();

                connection.Close( );
            }
        }
Example #9
0
 /// <summary>
 /// 得到一个表中所有字段
 /// </summary>
 /// <param name="serverID"></param>
 /// <param name="dbName"></param>
 /// <param name="tableName"></param>
 /// <returns></returns>
 public List<Model.Fields> GetFields(string serverID, string dbName, string tableName)
 {
     List<Model.Fields> fieldsList = new List<Model.Fields>();
     using (SQLiteConnection conn = new SQLiteConnection(Common.Config.GetConnectionString(serverID, dbName)))
     {
         conn.Open();
         using (SQLiteCommand cmd = new SQLiteCommand(string.Format("PRAGMA table_info({0})", tableName), conn))
         {
             SQLiteDataReader dr = cmd.ExecuteReader();
             while (dr.Read())
             {
                 fieldsList.Add(new Model.Fields()
                 {
                     Name = dr["name"].ToString(),
                     Type = dr["type"].ToString(),
                     IsNull = "1" != dr["notnull"].ToString(),
                     IsPrimaryKey = "1" == dr["pk"].ToString(),
                     Default = dr["dflt_value"].ToString(),
                     IsIdentity = "1" == dr["pk"].ToString() && "INTEGER" == dr["type"].ToString(),
                     DotNetType = GetFieldType(dr["type"].ToString(), "1" != dr["notnull"].ToString()),
                     DotNetSqlType = GetFieldSqlType(dr["type"].ToString()),
                     Note = "",
                     Length = -1
                 });
             }
             dr.Close();
             dr.Dispose();
         }
     }
     return fieldsList;
 }
Example #10
0
        /// <summary>
        /// sinartisi pou fortonei ola ta characteristics gia ena sigkekrimeno order id
        /// </summary>
        public static List<Characteristics> LoadCharacteristicsInOrder(int order_id)
        {
            List<Characteristics> characteristics = LoadCharacteristics();
            List<Characteristics> characteristicsInOrder = new List<Characteristics>();
            DBOpenClose(() =>
            {
                string sql = "select characteristics_id from characteristicsInOrders where order_id ='" + order_id + "'";
                SQLiteCommand command = new SQLiteCommand(sql, m_dbConnection);

                SQLiteDataReader reader = command.ExecuteReader();
                try
                {
                    while (reader.Read())
                    {
                        int characteristics_id = reader.GetInt32(0);

                        foreach (Characteristics ch in characteristics)
                        {
                            if (ch.Id == characteristics_id)
                                characteristicsInOrder.Add(ch);
                        }
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine("LoadCharacteristicsInOrder " + ex.Message);
                }

            });
            return characteristicsInOrder;
        }
Example #11
0
 public bool IsValid(string username)
 {
     var myDirectory = new DirectoryInfo(AppDomain.CurrentDomain.BaseDirectory);
     string parentDirectory = myDirectory.Parent.FullName;
     using (var cn = new SQLiteConnection(string.Format(@"Data Source={0}{1} Version=3;", parentDirectory, ConfigurationManager.ConnectionStrings["connectionstring"].ConnectionString)))
     {
         string _sql = @"SELECT id FROM Users " +
                "WHERE Name = '"+username+"';";
         cn.Open();
         var cmd = new SQLiteCommand(_sql, cn);
         var reader = cmd.ExecuteReader();
         if (reader.HasRows)
         {
             reader.Dispose();
             cmd.Dispose();
             return true;
         }
         else
         {
             reader.Dispose();
             cmd.Dispose();
             return false;
         }
     }
 }
Example #12
0
        /// <summary>
        /// sinartisi pou fortonei apo tin basi ola ta characteristics
        /// </summary>
        public static List<Characteristics> LoadCharacteristics()
        {
            List<Characteristics> characteristics = new List<Characteristics>();
            DBOpenClose(() =>
            {
                string sql = "select * from characteristics";
                SQLiteCommand command = new SQLiteCommand(sql, m_dbConnection);

                SQLiteDataReader reader = command.ExecuteReader();
                try
                {
                    while (reader.Read())
                    {
                        Characteristics characteristic = new Characteristics(reader.GetInt32(0), reader.GetString(1), reader.GetDouble(2));
                        characteristics.Add(characteristic);
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine("LoadCharacteristics " + ex.Message);
                }

            });
            return characteristics;
        }
        public override void update()
        {
            //Create a Dictionary to hold the receivers saved in the database
            Dictionary<string, Receiver> receivers = new Dictionary<string, Receiver>();

            //Create a new connection to the database
            using (SQLiteConnection m_dbConnection = new SQLiteConnection(@"Data Source=database.sqlite;Version=3;"))
            {
                //Open database connection
                m_dbConnection.Open();


                using (SQLiteCommand command = m_dbConnection.CreateCommand())
                {
                    //Select everything from the 'receivers' table
                    SQLiteCommand getReceivers = new SQLiteCommand("SELECT * FROM receivers", m_dbConnection);
                    SQLiteDataReader reader = getReceivers.ExecuteReader();

                    //Read every entry in the receivers table
                    while (reader.Read())
                    {
                        string name = (string)reader["name"];
                        Receiver battery = new Receiver((string)reader["name"], (double)reader["weight"], (int)reader["channelCount"], (int)reader["minVoltage"], (int)reader["maxVoltage"]);
                        //Add the battery into the dictionary using the name as the key and a new Receiver object as the value
                        receivers.Add(name, battery);
                    }
                }
                //Close the database connection
                m_dbConnection.Close();
            }
            //Save the updated savedReceiver list 
            savedReceivers = receivers;
        }
Example #14
0
 public List<HistoryRow> getAll()
 {
     List<HistoryRow> list = new List<HistoryRow>();
     Debug.WriteLine("Read history");
     try
     {
         string sql = "select * from history order by date asc";
         conn.Open();
         SQLiteCommand command = new SQLiteCommand(sql, conn);
         SQLiteDataReader reader = command.ExecuteReader();
         while (reader.Read())
         {
             list.Add(new HistoryRow(reader.GetInt16(0), reader.GetString(3), reader.GetString(2), reader.GetString(1)));
         }
     }
     catch (SQLiteException e)
     {
         Debug.WriteLine("Not connected : " + e.ToString());
         return list;
     }
     finally
     {
         Debug.WriteLine("End..");
         conn.Close();
     }
     return list;
 }
Example #15
0
        public static bool IsExistingClientByHostname(string hostname)
        {
            bool clientExists = false;

            string connStr = ConfigurationManager.ConnectionStrings["uWiMPConnString"].ConnectionString;
            SQLiteConnection conn = new SQLiteConnection(connStr);
            SQLiteDataReader reader;

            SQLiteCommand cmd = new SQLiteCommand("SELECT Hostname FROM `MPClients` WHERE Hostname = $Hostname", conn);
            cmd.Parameters.Add("$Hostname", DbType.String, 255).Value = hostname.ToLower();

            try
            {
                conn.Open();
                reader = cmd.ExecuteReader(CommandBehavior.Default);
                if (reader.HasRows)
                    clientExists = true;
            }
            catch (SQLiteException ex)
            {
                return false;
            }
            finally
            {
                conn.Close();
            }

            return clientExists;
        }
 public static DataTable buscaDatosPlural2()
 {
     DataTable tabla = new dataCredito.datosSing2DataTable();
     using (SQLiteConnection con = new SQLiteConnection(Datos.conexion))
     {
         using (SQLiteCommand comando = new SQLiteCommand())
         {
             comando.CommandText = "select * from datosPlural2";
             comando.Connection = con;
             con.Open();
             SQLiteDataReader lector = comando.ExecuteReader();
             while (lector.Read())
             {
                 DataRow fila = tabla.NewRow();
                 fila["nombre"] = lector.GetString(0);
                 fila["direccion"] = lector.GetString(1);
                 fila["direccion2"] = lector.GetString(2);
                 fila["ciudad"] = lector.GetString(3);
                 fila["id"] = lector.GetString(4);
                 fila["idCliente"] = lector.GetInt32(5);
                 fila["anio"] = lector.GetInt32(6);
                 fila["asesor"] = lector.GetString(7);
                 fila["cantidad"] = lector.GetString(8);
                 fila["cantidadL"] = lector.GetString(9);
                 fila["fecha"] = lector.GetDateTime(10);
                 fila["meses"] = lector.GetString(11);
                 fila["pie"] = lector.GetString(12);
                 tabla.Rows.Add(fila);
             }
         }
         con.Close();
     }
     return (tabla);
 }
 public FrmEdytujKlienta(int id_)
 {
     InitializeComponent();
     id = id_;
     using (SQLiteConnection conn = new SQLiteConnection(connString))
     {
         conn.Open();
         SQLiteCommand command = new SQLiteCommand(conn);
         command.CommandText = "SELECT * FROM Klienci WHERE [email protected]";
         command.Parameters.Add(new SQLiteParameter("@id", id));
         using (command)
         {
             using (SQLiteDataReader rdr = command.ExecuteReader())
             {
                 while (rdr.Read())
                 {
                     txt_id.Text = rdr.GetValue(0).ToString();
                     txt_imie.Text = rdr.GetValue(1).ToString();
                     txt_nazwisko.Text = rdr.GetValue(2).ToString();
                     txt_pesel.Text = rdr.GetValue(3).ToString();
                     txt_nr_dowodu.Text = rdr.GetValue(4).ToString();
                     txt_nr_telefonu.Text = rdr.GetValue(5).ToString();
                     txt_email.Text = rdr.GetValue(6).ToString();
                     txt_miejscowosc.Text = rdr.GetValue(7).ToString();
                     txt_kod_pocztowy.Text = rdr.GetValue(8).ToString();
                     txt_ulica.Text = rdr.GetValue(9).ToString();
                     txt_nr_domu.Text = rdr.GetValue(10).ToString();
                 }
             }
         }
         conn.Close();
     }
 }
Example #18
0
        public static List<ServerData> GetAllServerData(SQLiteConnection database)
        {
            string query = String.Format("SELECT [server_id], [name], [description], [location], [image] " +
                  "[sensor_1_name], [sensor_2_name], [sensor_3_name], [sensor_4_name], " +
                  "[sensor_1_unit], [sensor_2_unit], [sensor_3_unit], [sensor_4_unit], " +
                  "[sensor_1_id], [sensor_2_id], [sensor_3_id], [sensor_4_id]," +
                  "[sensor_1_range], [sensor_2_range], [sensor_3_range], [sensor_4_range] " +
               "FROM [servers]");
             List<ServerData> serverList = new List<ServerData>();

             lock (database)
             {
            using (SQLiteCommand command = new SQLiteCommand(query, database))
            {
               if (command.Connection.State != ConnectionState.Open)
               {
                  command.Connection.Open();
               }
               SQLiteDataReader serverReader = command.ExecuteReader();

               while (serverReader.Read())
               {
                  serverList.Add(ResultToServerData(serverReader));
               }
               serverReader.Close();
            }
            database.Close();
             }
             return serverList;
        }
Example #19
0
        public void addElement(string value)
        {
            string[] values = value.Split('|');
            string moduleCode = values[0];
            string moduleName = "";

            SQLiteConnection con = new SQLiteConnection(Form1.dbConnectionString);

            try
            {
                con.Open();
                string query = "Select ModuleName from ModuleInformation where ModuleCode = '" + moduleCode + "'";
                SQLiteCommand command = new SQLiteCommand(query, con);
                SQLiteDataReader reader = command.ExecuteReader();

                while (reader.Read())
                {
                    moduleName = reader.GetString(0);
                }

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

            dataGridView1.Rows.Add(values[0], moduleName, values[1], values[2]);
        }
Example #20
0
		public static ArrayList GetData(string sql)
		{
			ArrayList rowList = new ArrayList();
			try
			{
				SQLiteConnection myConn = new SQLiteConnection(GetConnectionString());
				myConn.Open();

				SQLiteCommand sqCommand = new SQLiteCommand(sql);
				sqCommand.Connection = myConn;
				SQLiteDataReader reader = sqCommand.ExecuteReader();

				while (reader.Read())
				{
					object[] values = new object[reader.FieldCount];
					reader.GetValues(values);
					rowList.Add(values);
				}

				myConn.Close();
				reader.Close();
			}
			catch (Exception ex)
			{
				logger.Error(sql + " - " + ex.Message);
			}
			return rowList;
		}
Example #21
0
 private DoorInfo Retrieve(string DoorID)
 {
     var ret = new DoorInfo();
     var cs = ConfigurationManager.ConnectionStrings["DoorSource"].ConnectionString;
     var conn = new SQLiteConnection(cs);
     conn.Open();
     var cmd = new SQLiteCommand(conn);
     cmd.CommandText = "SELECT DoorID, Location, Description, EventID FROM Doors WHERE DoorID = @DoorID LIMIT 1";
     cmd.Parameters.Add(new SQLiteParameter("@DoorID", DoorID));
     SQLiteDataReader res = null;
     try
     {
         res = cmd.ExecuteReader();
         if (res.HasRows && res.Read())
         {
             ret.DoorID = DoorID;
             ret.Location = res.GetString(1);
             ret.Description = res.GetString(2);
             ret.EventID = res.GetInt64(3);
         }
         return ret;
     }
     catch(Exception ex)
     {
         throw;
     }
     finally
     {
         if (null != res && !res.IsClosed)
             res.Close();
     }
 }
Example #22
0
        public String GetUrl()
        {
            String url = "";
            try
            {
                SQLiteConnection myConn = new SQLiteConnection(strConn);
                myConn.Open();
                string sql = "SELECT * FROM EMPRESA";
                SQLiteCommand command = new SQLiteCommand(sql, myConn);
                SQLiteDataReader reader = command.ExecuteReader();
                while (reader.Read())
                {
                    url = reader["UrlCore"].ToString();
                }

                myConn.Close();
            }
            catch (Exception e)
            {
                Console.WriteLine("ERROR: {0}", e.ToString());

            }

            return url;
        }
        public addDeletionInstructionDialog(string workingDirectory, modEditor me, SQLiteConnection conn, int editing)
        {
            InitializeComponent();
            this.workingDirectory = workingDirectory;
            this.me = me;
            this.conn = conn;
            this.editing = editing;

            if (editing != 0)
            {
                string sql = "SELECT file_name, type FROM files_delete WHERE id = " + editing + " LIMIT 1";
                SQLiteCommand command = new SQLiteCommand(sql, conn);
                SQLiteDataReader reader = command.ExecuteReader();
                while (reader.Read())
                {
                    char[] chars = { '/' };
                    string[] pieces = reader["file_name"].ToString().Split(chars, 2);
                    if (pieces.Length == 1)
                        fileName.Text = pieces[0];
                    else if (pieces.Length == 2)
                    {
                        filePrefix.SelectedItem = pieces[0];
                        fileName.Text = pieces[1];
                    }

                    whatIs_Dir.Checked = reader["type"].ToString() == "dir";
                    whatIs_File.Checked = reader["type"].ToString() == "file";
                }
            }
        }
Example #24
0
        public ObservableCollection<Jewelry> GetAll()
        {
            using (SQLiteConnection conn = new SQLiteConnection(@"Data Source=c:/xhz/ms.db;"))
            //using (SQLiteConnection conn = new SQLiteConnection(@"Data Source=DB/ms.db;"))
            {
                conn.Open();

                string sql = string.Format("select * from detail");

                SQLiteCommand cmd = new SQLiteCommand(sql, conn);

                using (SQLiteDataReader dr1 = cmd.ExecuteReader())
                {
                    while (dr1.Read())
                    {
                        var d = dr1;
                        var guid = dr1.GetValue(0);
                        var data = dr1.GetValue(1);
                        //var insert = dr1.GetValue(2);
                        //var update = dr1.GetValue(3);

                        //没有把helper推送到服务器
                        Jewelry je1 = helper.xmlPras(data.ToString());
                        _OCJ.Add(je1);
                    }
                }

                conn.Close();
            }
            OCJ.Add(Jewelry.GetExample());
            return OCJ;
        }
Example #25
0
        //public static int Insert(string dbFile, string sql,)
        public static ObservableCollection<Jewelry> GetAll()
        {
            ObservableCollection<Jewelry> ob = new ObservableCollection<Jewelry>();

            using (SQLiteConnection conn = new SQLiteConnection(@"Data Source=c:/xhz/ms.db;"))
            //using (SQLiteConnection conn = new SQLiteConnection(@"Data Source=DB/ms.db;"))
            {
                conn.Open();

                string sql = string.Format("select * from detail");

                SQLiteCommand cmd = new SQLiteCommand(sql, conn);

                using (SQLiteDataReader dr1 = cmd.ExecuteReader())
                {
                    while (dr1.Read())
                    {
                        var d = dr1;
                        var dd = dr1.GetValue(0);
                        var data = dr1.GetValue(1);
                        var insert = dr1.GetValue(2);
                        var update = dr1.GetValue(3);
                    }
                }

                conn.Close();
            }

            ob.Add(new Jewelry());

            return ob;
        }
Example #26
0
 public void SetZoeziBContent()
 {
     category = "Kuongea";
     question = "Andika majibu ya salamu haya:";
     questionTxtBlock.Text = question;
     int count = 0;
     string[] questions= new string[5];
     string[] answers = new string[5];
     string query = "select salamu,jibu from salamu_info";
     try
     {
         SQLiteCommand sqliteCommand = new SQLiteCommand(query, Database.GetDatabaseConnection());
         sqliteCommand.ExecuteNonQuery();
         SQLiteDataReader reader = sqliteCommand.ExecuteReader();
         while (reader.Read() && count < 4)
         {
             questions[count + 1] = reader.GetString(0);
             answers[count + 1] = reader.GetString(1).ToLower();
             count++;
         }
     }
     catch (Exception ex) { MessageBox.Show(ex.Message); }
    
     qn1TxtBlock.Text += questions[1];
     qn1TxtBlock.Tag = answers[1];
     qn2TxtBlock.Text += questions[2];
     qn2TxtBlock.Tag = answers[2];
     qn3TxtBlock.Text += questions[3];
     qn3TxtBlock.Tag = answers[3];
     qn4TxtBlock.Text += questions[4];
     qn4TxtBlock.Tag = answers[4];
 }
Example #27
0
        public Block_Edit(int id_)
        {
            InitializeComponent();
            id = id_;

            using (SQLiteConnection conn = new SQLiteConnection(connString))
            {
                conn.Open();
                SQLiteCommand command = new SQLiteCommand(conn);
                command.CommandText = "SELECT * FROM Block WHERE [email protected]";
                command.Parameters.Add(new SQLiteParameter("@id", id));
                using (command)
                {
                    using (SQLiteDataReader rdr = command.ExecuteReader())
                    {
                        while (rdr.Read())
                        {

                            labelName.Text = rdr.GetValue(1).ToString();
                            txtImieNazw.Text = rdr.GetValue(1).ToString();

                        }
                    }
                }
                conn.Close();
            }
        }
Example #28
0
        /// <summary>
        /// Возвращает список неотправленных на сервер сессий чтения
        /// </summary>
        public List<RfidSession> GetUnshippedTags()
        {
            var sessions = new List<RfidSession>();
            var sessionCmd = new SQLiteCommand(@"SELECT * from reading_sessions where delivery_status <> " + (int)RfidSession.DeliveryStatus.Shipped, connection);

            using (var sessionReader = sessionCmd.ExecuteReader())
            {
                while (sessionReader.Read())
                {
                    var session = new RfidSession
                        {
                            id = sessionReader.GetInt32(0),
                            time = sessionReader.GetString(1),
                            location = sessionReader.GetString(2),
                            deliveryStatus = (RfidSession.DeliveryStatus)sessionReader.GetInt32(3),
                            readingStatus = (RfidSession.ReadingStatus)sessionReader.GetInt32(4),
                            sessionMode = (RfidSession.SessionMode)sessionReader.GetInt32(5)
                        };

                    var tagCmd = new SQLiteCommand(@"SELECT * from tubes where session_id = " + session.id, connection);
                    using (var tagReader = tagCmd.ExecuteReader())
                    {
                        while (tagReader.Read())
                        {
                            session.tags.Add(tagReader.GetString(1));
                        }
                    }
                    sessions.Add(session);
                }
            }
            return sessions;
        }
        public List<AttachmentDetail> getWitAttachments()
        {
            List<AttachmentDetail> attachments;
            try
            {
                sql_con = new SQLiteConnection(Common.localDatabasePath, true);
                sql_cmd = new SQLiteCommand("select * from wit_attachments", sql_con);

                sql_con.Open();
                SQLiteDataReader reader = sql_cmd.ExecuteReader();

                attachments = new List<AttachmentDetail>();
                while (reader.Read())
                {
                    AttachmentDetail attachment = new AttachmentDetail();
                    attachment.fileAssociationId = StringUtils.ConvertFromDBVal<string>(reader["file_association_id"]);
                    attachment.fileName = StringUtils.ConvertFromDBVal<string>(reader["file_name"]);
                    attachment.witId = StringUtils.ConvertFromDBVal<string>(reader["wit_id"]);
                    attachment.fileMimeType = StringUtils.ConvertFromDBVal<string>(reader["file_mime_type"]);
                    attachment.fileAssociationId = StringUtils.ConvertFromDBVal<string>(reader["file_association_id"]);
                    attachment.seqNumber = StringUtils.ConvertFromDBVal<string>(reader["seq_number"]);
                    attachment.extention = StringUtils.ConvertFromDBVal<string>(reader["extention"]);
                   
                    attachments.Add(attachment);
                }

            }
            catch (SQLiteException e) { throw e; }
            finally { sql_con.Close(); }

            return attachments;

        }
 public Dictionary<string, List<string>> ListPageCategories(long pageRevisionID)
 {
     using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Suppress))
     {
         using (SQLiteConnection conn = new SQLiteConnection(DatabaseManager.DatabaseEngine.ConnectionString))
         {
             conn.Open();
             SQLiteCommand cmd = new SQLiteCommand(Procedures["List Categories for Page Revision"], conn);
             cmd.Parameters.Add(NewParameter("@PageRevisionID", pageRevisionID, DbType.Int64));
             Dictionary<string, List<string>> cats = new Dictionary<string, List<string>>();
             using (SQLiteDataReader reader = cmd.ExecuteReader(CommandBehavior.CloseConnection))
             {
                 while (reader.Read())
                 {
                     string catsetname = reader["CategorySetName"].ToString();
                     string catname = reader["CategoryName"].ToString();
                     List<string> catlist;
                     if (!cats.TryGetValue(catsetname, out catlist))
                     {
                         catlist = new List<string>();
                         cats.Add(catsetname, catlist);
                     }
                     catlist.Add(catname);
                 }
                 reader.Close();
                 return cats;
             }
         }
     }
 }