Beispiel #1
0
        private void DeleteExample()
        {
            Connection connection = new Connection();

            connection.OpenConnection();

            CommandSql command = new CommandSql(Resources.sqlQueryDelete, connection);

            command.Command.Parameters.AddWithValue("@studentId", 1);
            command.Command.ExecuteNonQuery();

            connection.CloseConnection();
        }
Beispiel #2
0
        private void InsertExample()
        {
            Connection connection = new Connection();

            connection.OpenConnection();

            CommandSql command = new CommandSql(Resources.sqlQueryInsert, connection);

            command.Command.Parameters.AddWithValue("@studentName", "Alexis");
            command.Command.Parameters.AddWithValue("@studentSurname", "Mengual Vázquez");
            command.Command.ExecuteNonQuery();

            connection.CloseConnection();
        }
Beispiel #3
0
        private void SelectExample()
        {
            Connection connection = new Connection();

            connection.OpenConnection();
            CommandSql command = new CommandSql(Resources.sqlQuery, connection);
            ReaderSql  reader  = new ReaderSql(command);

            string[] columns = { "StudentId", "Name", "Surname", "Birthday" };
            string   result  = reader.ReadQuery(columns);

            connection.CloseConnection();
            Console.WriteLine(result);
            Console.ReadLine();
        }
Beispiel #4
0
 public ReaderSql(CommandSql command)
 {
     Reader = command.Command.ExecuteReader();
 }